コード例 #1
0
ファイル: Generator.php プロジェクト: madflow/cheesecake
 /**
  * Let's do this ...
  * @param $template string The path or url to a tasty cheesecake template
  * @param $params array Optional parameters that are merged with existing
  *                      params from a cheesecake.json file :O
  * @param $options array Options
  */
 public function __construct($template, array $params = [], array $options = [])
 {
     $this->template = $template;
     $this->templateType = $this->detectTemplateType($template);
     $this->params = $params;
     $this->output = $this->getoa($options, self::OPT_OUTPUT, '.');
     $this->noInteraction = $this->getoa($options, self::OPT_NO_INTERACTION, false);
     $options = ['pragmas' => [\Mustache_Engine::PRAGMA_FILTERS]];
     $this->mustache = new \Mustache_Engine($options);
     $this->mustache->addHelper('string', ['toLowerCase' => function ($value) {
         return Stringy::toLowerCase($value);
     }, 'toUpperCase' => function ($value) {
         return Stringy::toUpperCase($value);
     }, 'upperCaseFirst' => function ($value) {
         return Stringy::upperCaseFirst($value);
     }, 'lowerCaseFirst' => function ($value) {
         return Stringy::lowerCaseFirst($value);
     }, 'humanize' => function ($value) {
         return Stringy::humanize($value);
     }, 'camelize' => function ($value) {
         return Stringy::camelize($value);
     }, 'upperCamelize' => function ($value) {
         return Stringy::upperCamelize($value);
     }, 'slugify' => function ($value) {
         return Stringy::slugify($value);
     }]);
     $this->fs = new Filesystem();
 }
コード例 #2
0
ファイル: FileNameParser.php プロジェクト: czogori/dami
 /**
  * Constructor.
  *
  * @param string $filename Filename of migration.
  */
 public function __construct($filename)
 {
     $items = explode('_', $filename);
     $this->version = $items[0];
     $this->name = ltrim($filename, $this->version . '_');
     $this->name = basename($this->name, '.php');
     $this->className = S::upperCamelize($this->name) . 'Migration';
 }
コード例 #3
0
 protected function getSkeleton($name)
 {
     $skeleton = new Skeleton($this->getSkeletonPath('entity'));
     $name = S::upperCamelize($name);
     $skeleton->entity_name = $name;
     $skeleton->table = Inflector::pluralize(S::replace(S::dasherize($name), '-', '_'));
     return $skeleton;
 }
コード例 #4
0
ファイル: LoggerController.php プロジェクト: snivs/semanti
 public function actionIndex()
 {
     // --------------------------- TITLE -----------------------------------
     $this->getView()->title .= ' :: ' . S::upperCamelize($this->action->id);
     // log -----------------------------------------------------------------
     AppLogger::log(['method' => __METHOD__, 'line' => __LINE__, 'requestParams' => Yii::$app->request->getQueryParams()], AppLogger::WARNING, AppLogger::CATEGORY_TEST);
     // ---------------------------------------------------------------------
     return $this->render('/index/index');
 }
コード例 #5
0
ファイル: SchemaEntity.php プロジェクト: timoran/otynirm
 public function __construct($className, array $values = array(), array $map = array(), $tableName = null)
 {
     $this->className = S::upperCamelize($className);
     if (empty($tableName)) {
         $this->tableName = S::underscored($className);
     }
     $this->values = $values;
     $this->map = $map;
 }
コード例 #6
0
ファイル: IndexController.php プロジェクト: snivs/semanti
 public function actionUrl()
 {
     // --------------------------- TITLE -----------------------------------
     $this->getView()->title .= ' :: ' . S::upperCamelize($this->action->id);
     // debug info ----------------------------------------------------------
     AppDebug::dump(['method' => __METHOD__, 'line' => __LINE__, 'module' => $this->getModuleName(), 'controller' => $this->getControllerName(), 'action' => $this->getActionName(), '/profile/login' => Url::toRoute('/profile/login'), '/profile/logout' => Url::toRoute('/profile/logout'), '/profile/signup' => Url::toRoute('/profile/signup'), '/request-password-reset' => Url::toRoute('request-password-reset'), 'site/captcha' => Url::toRoute('site/captcha')]);
     // ---------------------------------------------------------------------
     // TODO
     return $this->render('index');
 }
コード例 #7
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelper('dialog');
     $name = $input->getArgument('name');
     if (!$name) {
         $name = $dialog->ask($output, 'Name of module: ');
     }
     $name = strtolower($name);
     $namespace = $input->getArgument('namespace');
     if (!$namespace) {
         $namespace = $dialog->ask($output, 'Namespace for this module: ', S::upperCamelize($name));
     }
     $this->createDirectories($output, $this->createModuleDirectory($namespace));
     $file = $this->createModuleDirectory($namespace) . 'config.php';
     $config = new Config($name);
     $config->save($file);
     $output->writeln("Created <info>{$file}</info>");
     //create module class
 }
コード例 #8
0
 /**
  * @dataProvider upperCamelizeProvider()
  */
 public function testUpperCamelize($expected, $str, $encoding = null)
 {
     $result = S::upperCamelize($str, $encoding);
     $this->assertInternalType('string', $result);
     $this->assertEquals($expected, $result);
 }
コード例 #9
0
ファイル: StringyLoader.php プロジェクト: lablog/stringy
 public function upperCamelize($string)
 {
     return Stringy::upperCamelize($string);
 }
コード例 #10
0
ファイル: Otynirm.php プロジェクト: timoran/otynirm
 private function getRealEntitie($attr)
 {
     $attr = S::upperCamelize($attr);
     if ($this->getTypeRelation($attr) == SchemaEntity::ONE) {
         return $attr;
     }
     return substr($attr, 0, strlen($attr) - 1);
 }
コード例 #11
0
ファイル: Schema.php プロジェクト: sqrt-pro/db
 protected function makeItemBitmask($def, &$func, &$before, &$after)
 {
     $col = $def['column'];
     $setter = Item::MakeSetterName($col);
     $getter = Item::MakeGetterName($col);
     $name_for = StaticStringy::upperCamelize('get name for ' . $col);
     $getter_arr = StaticStringy::upperCamelize('get ' . $col . ' arr');
     $adder = StaticStringy::camelize('add ' . $col);
     $hasser = StaticStringy::camelize('has ' . $col);
     $remove = StaticStringy::camelize('remove ' . $col);
     $const = $names = '';
     $func[] = "  public function {$hasser}(\${$col})\n" . "  {\n" . "    return \$this->bitCheck('{$col}', \${$col});\n" . "  }";
     $func[] = "  public function {$getter}()\n" . "  {\n" . "    return \$this->bitGet('{$col}', array_keys(static::{$getter_arr}()));\n" . "  }";
     $func[] = "  public function {$setter}(array \$bits, \$clean = true)\n" . "  {\n" . "    return \$this->bitSet('{$col}', \$bits, \$clean);\n" . "  }";
     $func[] = "  /** @return static */\n" . "  public function {$adder}(\${$col})\n" . "  {\n" . "    if (!empty(\${$col}) && !static::{$name_for}(\${$col})) {\n" . "      Exception::ThrowError(Exception::ENUM_BAD_VALUE, '{$col}', \${$col});\n" . "    }\n\n" . "    return \$this->bitAdd('{$col}', \${$col});\n" . "  }";
     $func[] = "  /** @return static */\n" . "  public function {$remove}(\${$col})\n" . "  {\n" . "    if (!empty(\${$col}) && !static::{$name_for}(\${$col})) {\n" . "      Exception::ThrowError(Exception::ENUM_BAD_VALUE, '{$col}', \${$col});\n" . "    }\n\n" . "    return \$this->bitRemove('{$col}', \${$col});\n" . "  }";
     if (!empty($def['options'])) {
         $i = 0;
         foreach ($def['options'] as $v) {
             $c = strtoupper($col . '_' . $v);
             $b = pow(2, $i++);
             $f = $hasser . StaticStringy::upperCamelize($v);
             $const[] = "  const {$c} = {$b};";
             $names[] = "    self::{$c} => '{$v}',";
             $func[] = "  public function {$f}()\n" . "  {\n" . "    return \$this->{$hasser}(static::{$c});\n" . "  }";
         }
         $before[] = join("\n", $const);
     }
     $before[] = "  protected static \${$col}_arr = array(\n" . join("\n", $names) . "\n  );";
     $after[] = "  public static function {$getter_arr}()\n" . "  {\n" . "    return static::\${$col}_arr;\n" . "  }";
     $after[] = "  public static function {$name_for}(\${$col})\n" . "  {\n" . "    \$a = static::{$getter_arr}();\n\n" . "    return isset(\$a[\${$col}]) ? \$a[\${$col}] : false;\n" . "  }";
 }
コード例 #12
0
ファイル: Item.php プロジェクト: sqrt-pro/db
 /**
  * Обработка изображения и сохранение в объект
  * $column - поле
  * $file - исходный файл
  * $filename - относительный путь выходного файла
  * $name - название файла
  * $size - "размерность" файла
  */
 protected function processImage($column, $file, $filename, $name = null, $size = false)
 {
     if (!is_file($file)) {
         Exception::ThrowError(Exception::FILE_NOT_EXISTS, $file);
     }
     $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
     $path = $this->getFilesPath() . $filename;
     /** @var Image $img */
     $method = 'prepareImageFor' . StaticStringy::upperCamelize($column);
     $img = call_user_func_array(array($this, $method), array($file, $size));
     if ($img instanceof Image) {
         $img->save($path);
         $w = $img->getWidth();
         $h = $img->getHeight();
     } else {
         $this->copyFile($file, $path);
         list($w, $h) = getimagesize($path);
     }
     $file_arr = array('file' => $filename, 'extension' => $ext, 'size' => filesize($path), 'name' => $name, 'width' => $w, 'height' => $h);
     if ($size) {
         $this->resetSerializedCache($column);
         $arr = $this->getSerialized($column);
         $arr[$size] = $file_arr;
     } else {
         $arr = $file_arr;
     }
     return $this->setSerialized($column, $arr);
 }