コード例 #1
0
ファイル: StringsTest.php プロジェクト: PaulAntunes/gclf-paul
 public function testStringToUnderScore()
 {
     $expectations = [["firstName", "first_name"]];
     foreach ($expectations as $expect) {
         $this->assertEquals($expect[1], \Packaged\Helpers\Strings::stringToUnderScore($expect[0]));
     }
 }
コード例 #2
0
ファイル: FormElement.php プロジェクト: packaged/form
 public function __construct(Form $form, $name, $type = self::TEXT, $label = null, $labelPosition = self::LABEL_BEFORE)
 {
     $name = Strings::stringToUnderScore($name);
     $this->_name = $name;
     $this->_id = $form->getId() . '-' . Strings::urlize($name);
     $this->setOption('name', $name);
     $this->setOption('id', $this->_id);
     $this->_type = $type;
     $this->_label = $label === null ? Strings::humanize($name) : $label;
     $this->_labelPosition = $labelPosition;
     $this->_form = $form;
 }
コード例 #3
0
ファイル: QlDao.php プロジェクト: packaged/dal
 /**
  * Retrieve the table name for this DAO
  *
  * @return string
  */
 public function getTableName()
 {
     if ($this->_tableName === null) {
         $class = get_called_class();
         $ns = Objects::getNamespace($class);
         $dirs = $this->getTableNameExcludeDirs();
         foreach ($dirs as $dir) {
             $ns = ltrim(Strings::offset($ns, $dir), '\\');
         }
         $this->_tableName = trim(Inflector::tableize(implode('_', [Strings::stringToUnderScore($ns), Inflector::pluralize(Objects::classShortname($class))])), '_ ');
         $this->_tableName = str_replace('__', '_', $this->_tableName);
     }
     return $this->_tableName;
 }
コード例 #4
0
use Packaged\Helpers\Path;
use Packaged\Helpers\Strings;
$output = '<?php
namespace Fortifi\\FortifiApi\\ActivityFeed\\Enums;

class ActivityFeedStoryEnum
{
  public static $storyTypes = [
';
$stories = Path::globRecursive(Path::build(__DIR__, 'Stories'));
foreach ($stories as $story) {
    $story = str_replace(__DIR__ . '/Stories/', '', $story);
    //Skip Abstracts and Non Story Classes
    if (Strings::startsWithAny($story, ['Abstract']) || !Strings::endsWith($story, 'Story.php')) {
        continue;
    }
    $part = explode('/', $story);
    $storyClass = array_pop($part);
    $storyClass = str_replace('Story.php', '', $storyClass);
    $storyNs = 'Fortifi\\FortifiApi\\ActivityFeed\\Stories\\' . implode('\\', $part);
    $key = Strings::stringToUnderScore($storyClass);
    //Skip Interfaces
    if (substr($key, 0, 2) == 'i_') {
        continue;
    }
    $output .= "    '{$key}' => '" . $storyNs . "\\" . $storyClass . "Story',\n";
}
$output .= '  ];
}
';
file_put_contents(Path::build(__DIR__, 'Enums', 'ActivityFeedStoryEnum.php'), $output);