コード例 #1
0
ファイル: FileLoader.php プロジェクト: thinframe/karma
 /**
  * Require all php files from provided directory
  *
  * @param      $path
  * @param bool $recursive
  */
 public static function doRequire($path, $recursive = true)
 {
     if (is_dir($path) && $recursive) {
         $children = scandir($path);
         foreach ($children as $child) {
             if ($child == '.' || $child == '..') {
                 continue;
             }
             self::doRequire($path . DIRECTORY_SEPARATOR . $child);
         }
     } elseif (is_file($path) && StaticStringy::endsWith($path, '.php')) {
         require_once $path;
     }
 }
コード例 #2
0
 /**
  * Caches all twig files
  *
  * @param        $dir
  * @param string $baseDir
  * @param        $applicationName
  */
 public function cacheTwigFilesFrom($dir, $baseDir = '', $applicationName)
 {
     foreach (scandir($dir) as $element) {
         if ($element == '.' || $element == '..') {
             continue;
         }
         if (is_dir($dir . DIRECTORY_SEPARATOR . $element)) {
             $this->cacheTwigFilesFrom($dir . DIRECTORY_SEPARATOR . $element, $baseDir . $element . DIRECTORY_SEPARATOR, $applicationName);
         } else {
             if (StaticStringy::endsWith($element, '.html.twig')) {
                 $this->twig->loadTemplate($applicationName . ":" . $baseDir . $element);
             }
         }
     }
 }
コード例 #3
0
 /**
  * @dataProvider endsWithProvider()
  */
 public function testEndsWith($expected, $str, $substring, $caseSensitive = true, $encoding = null)
 {
     $result = S::endsWith($str, $substring, $caseSensitive, $encoding);
     $this->assertInternalType('boolean', $result);
     $this->assertEquals($expected, $result);
 }
コード例 #4
0
ファイル: StringyLoader.php プロジェクト: lablog/stringy
 public function endsWith($string, $ending, $case = true)
 {
     return Stringy::endsWith($string, $ending, $case);
 }
コード例 #5
0
 /**
  * @inheritdoc
  */
 public function where($attribute, $operator = null, $value = null, $connector = "and")
 {
     // here we ignore the $connector parameter as it is not supported by the redmine api
     // validate the attribute
     if (!is_string($attribute)) {
         throw new QueryException("We only support string as the attribute name");
     }
     // validate the operator
     if ($operator !== null && !in_array($operator, static::$SUPPORTED_OPERATORS, true)) {
         throw new QueryException("Invalid operator given");
     }
     if ($operator === "=") {
         // if an equals is used we set the operator to the empty string
         $operator = "";
     }
     // validate the value
     if (empty($value)) {
         throw new QueryException("No value given");
     }
     // handle relations
     if ($value instanceof Model) {
         // handle relations in a custom way
         if (!StaticStringy::endsWith($attribute, "_id")) {
             $attribute .= "_id";
         }
         $value = $value->id();
     }
     // return a new query instance
     return new static($this->client, array_merge($this->conditions, ["{$attribute}" => "{$operator}{$value}"]), $this->limits);
 }
コード例 #6
0
 public function index($value, $params = array())
 {
     return Stringy::endsWith($value, array_get($params, 0), array_get($params, 1, false));
 }
コード例 #7
0
 /**
  * アーカイブ中のディレクトリ構造を除去します。
  * @param ZipOutputFile $archive
  * @throws SyntaxException 同名のファイルが存在する場合。
  */
 protected function flattenArchive(ZipOutputFile $archive)
 {
     $validator = new validator\FileLocationValidator();
     foreach ($archive->getListFiles() as $filename) {
         if (\Stringy\StaticStringy::endsWith($filename, '/')) {
             $archive->deleteFromName($directory);
         } else {
             $basename = $validator->getBasename($filename);
             if ($filename !== $basename) {
                 if (in_array(strtolower($basename), array_map('strtolower', $archive->getListFiles()))) {
                     throw SyntaxException(_('アーカイブ中に同名のファイルを含めることはできません: ') . $basename);
                 }
                 $archive->rename($filename, $basename);
             }
         }
     }
 }