MY_inflector.php

Ilari Mäkimattila -, 04/09/2009 01:11 pm

Download (515 Bytes)

 
1
<?php
2
3
class inflector extends inflector_Core {
4
        public static function singular($str, $count = NULL) {
5
                $parts = explode('_', $str);
6
7
                $last = parent::singular(array_pop($parts), $count);
8
9
                $pre = implode('_', $parts);
10
                if (strlen($pre)) $pre .= '_';
11
12
                return $pre.$last;
13
        }
14
15
        public static function plural($str, $count = NULL) {
16
                $parts = explode('_', $str);
17
18
                $last = parent::plural(array_pop($parts), $count);
19
20
                $pre = implode('_', $parts);
21
                if (strlen($pre)) $pre .= '_';
22
23
                return $pre.$last;
24
        }
25
}
26
27