コード例 #1
0
ファイル: Model.php プロジェクト: nanjingboy/clown
 public static function table()
 {
     static $table = null;
     if ($table !== null) {
         return $table;
     }
     if (!empty(static::$table)) {
         return static::$table;
     }
     $parts = explode('\\', get_called_class());
     $table = Helper::pluralize(Helper::underscore(array_pop($parts)));
     return $table;
 }
コード例 #2
0
ファイル: Base.php プロジェクト: nanjingboy/clown
 public function __construct($model)
 {
     $this->_model = $model;
     $namespaces = explode('\\', get_called_class());
     $type = Helper::underscore(array_pop($namespaces));
     $properties = get_class_vars(get_class($model));
     if (!empty($properties[$type])) {
         foreach ($properties[$type] as $metadata) {
             $name = array_shift($metadata);
             if (empty($metadata['class'])) {
                 $metadata['class'] = ucfirst(Helper::singularize($name));
             }
             $metadata['class'] = '\\' . ltrim($metadata['class'], '\\');
             $this->_metadata[$name] = $metadata;
         }
     }
 }
コード例 #3
0
ファイル: HelperTest.php プロジェクト: nanjingboy/clown
 public function testUnderscore()
 {
     $this->assertEquals('string_to_underscore', Helper::underscore('string_to_underscore'));
     $this->assertEquals('string_to_underscore', Helper::underscore('StringToUnderscore'));
 }