Changeset 4554

Show
Ignore:
Timestamp:
06/24/08 05:07:31 (7 months ago)
Author:
jwage
Message:

Documentation and removing functions which were added but never used anywhere.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/lib/Doctrine/Inflector.php

    r4378 r4554  
    2121 
    2222/** 
    23  * Doctrine_Inflector has static methods for inflecting text 
     23 * Doctrine inflector has static methods for inflecting text 
    2424 *  
    2525 * The methods in these classes are from several different sources collected 
     
    3939{ 
    4040    /** 
    41     * pluralize 
    42     * 
    43     * @param    string $word English noun to pluralize 
    44     * @return   string Plural noun 
    45     */ 
     41     * Pluralize an English noun. Converts 'Category' to 'Categories'. 
     42     * 
     43     * @param    string $word English noun to pluralize 
     44     * @return   string $word Plural noun 
     45     */ 
    4646    public static function pluralize($word) 
    4747    { 
     
    104104 
    105105    /** 
    106     * singularize 
    107     * 
    108     * @param    string    $word    English noun to singularize 
    109     * @return   string Singular noun. 
    110     */ 
     106     * Singularize an English noun. Converts 'Quizzes' to 'Quiz'. 
     107     * 
     108     * @param    string  $word    English noun to singularize 
     109     * @return   string  $word    Singular noun. 
     110     */ 
    111111    public static function singularize($word) 
    112112    { 
     
    178178 
    179179    /** 
    180      * variablize 
    181      *  
    182      * @param string $word  
    183      * @return void 
    184      */ 
    185     public static function variablize($word) 
    186     { 
    187         $word = self::camelize($word); 
    188  
    189         return strtolower($word[0]) . substr($word, 1); 
    190     } 
    191  
    192     /** 
    193      * tableize 
    194      * 
    195      * @param string $name 
    196      * @return void 
    197      */ 
    198     public static function tableize($name) 
     180     * Convert word in to the format for a Doctrine table name. Converts 'ModelName' to 'model_name' 
     181     * 
     182     * @param  string $word  Word to tableize 
     183     * @return string $word  Tableized word 
     184     */ 
     185    public static function tableize($word) 
    199186    { 
    200187        // Would prefer this but it breaks unit tests. Forces the table underscore pattern 
    201188        // return self::pluralize(self::underscore($name)); 
    202         return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $name)); 
    203     } 
    204  
    205     /** 
    206      * classify 
    207      * 
    208      * @param string $word 
     189        return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $word)); 
     190    } 
     191 
     192    /** 
     193     * Convert a word in to the format for a Doctrine class name. Converts 'table_name' to 'TableName' 
     194     * 
     195     * @param string  $word  Word to classify 
     196     * @return string $word  Classified word 
    209197     */ 
    210198    public static function classify($word) 
     
    214202 
    215203    /** 
    216      * classifyCallback 
    217      * 
    218204     * Callback function to classify a classname properly. 
    219205     * 
    220      * @param array $matches An array of matches from a pcre_replace call 
    221      * @return string A string with matches 1 and mathces 3 in upper case. 
     206     * @param  array  $matches An array of matches from a pcre_replace call 
     207     * @return string $string   A string with matches 1 and mathces 3 in upper case. 
    222208     */ 
    223209    public static function classifyCallback($matches) 
     
    227213 
    228214    /** 
    229      * camelize 
    230      * 
    231      * @param string $word  
    232      * @return void 
    233      */ 
    234     public static function camelize($word) 
    235     { 
    236         if (preg_match_all('/\/(.?)/', $word, $got)) { 
    237             foreach ($got[1] as $k => $v){ 
    238                 $got[1][$k] = '::' . strtoupper($v); 
    239             } 
    240  
    241             $word = str_replace($got[0], $got[1], $word); 
    242         } 
    243  
    244         return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9^:]+/', ' ', $word))); 
    245     } 
    246  
    247     /** 
    248      * seemsUtf8 
     215     * Check if a string has utf7 characters in it 
    249216     * 
    250217     * By bmorel at ssi dot fr 
    251218     * 
    252      * @param string $str  
    253      * @return void 
     219     * @param  string $string 
     220     * @return boolean $bool 
    254221     */ 
    255222    public static function seemsUtf8($string) 
     
    272239     
    273240    /** 
    274      * unaccent 
    275      * 
    276      * @param string $string  
    277      * @return void 
     241     * Remove any illegal characters, accents, etc. 
     242     * 
     243     * @param  string $string  String to unaccent  
     244     * @return string $string  Unaccented string 
    278245     */ 
    279246    public static function unaccent($string) 
     
    410377 
    411378    /** 
    412      * urlize 
    413      * 
    414      * @param string $text  
    415      * @return void 
     379     * Convert any passed string to a url friendly string. Converts 'My first blog post' to 'my-first-blog-post' 
     380     * 
     381     * @param  string $text  Text to urlize 
     382     * @return string $text  Urlized text 
    416383     */ 
    417384    public static function urlize($text) 
     
    431398        return trim($text, '-'); 
    432399    } 
    433  
    434     /** 
    435      * underscore 
    436      * 
    437      * @param string $word  
    438      * @return void 
    439      */ 
    440     public static function underscore($word) 
    441     { 
    442         return strtolower(preg_replace('/[^A-Z^a-z^0-9^\/]+/', '_', 
    443                preg_replace('/([a-z\d])([A-Z])/', '\1_\2', 
    444                preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1_\2', 
    445                preg_replace('/::/', '/', $word))))); 
    446     } 
    447400}