Beispiel #1
0
 /**
  * Work the model class based on the table name, and cache it for later.
  *
  * @param Table $table The table to get a model for
  *
  * @return string The name of a model class
  */
 protected function getModelClass($table)
 {
     if (isset(static::$modelClassCache[$table->name])) {
         return static::$modelClassCache[$table->name];
     }
     $namespace = null;
     $config = Config::get($table->instance->name);
     if (isset($config->model_namespace)) {
         $namespace = $config->model_namespace;
     }
     if ($namespace === null) {
         $config = Config::get('default');
         if (isset($config->model_namespace)) {
             $namespace = $config->model_namespace;
         }
         if ($namespace === null) {
             $namespace = 'Models';
         }
     }
     $modelClass = Str::singularize($table->name);
     $modelClass = Str::camelCaps($namespace . '\\' . $modelClass);
     if (!class_exists($modelClass)) {
         $modelClass = Model::class;
     }
     return static::$modelClassCache[$table->name] = $modelClass;
 }
Beispiel #2
0
 public function setHeader($key, $value)
 {
     $key = Str::camelCaps($key);
     return header("{$key}: {$value}");
 }
Beispiel #3
0
 /**
  * Execute the command.
  */
 public function executeCommand()
 {
     $command = $this->command;
     $class = 'Pug\\Cli\\Command\\' . Str::camelCaps($command);
     if (!class_exists($class)) {
         Prompt::outputend(ANSI::fg('The command "' . $command . '" could not be found.' . "\n", ANSI::RED));
         $this->command = 'help';
         Help::execute($this);
         exit(127);
     }
     $class::execute($this);
 }
Beispiel #4
0
 /**
  * Tests conversion of naughty strings to camelCase.
  *
  * @dataProvider bigListOfNaughtyStrings
  *
  * @covers Molovo\Str\Str::slug
  */
 public function testCamelCapsWithNaughtyStrings($string)
 {
     $string = Str::camelCaps(base64_decode($string));
     if (!empty($string)) {
         verify($string)->regExp('/[a-zA-Z0-9]/');
         verify($string)->regExp('/^[A-Z0-9]/');
     }
 }