コード例 #1
0
 /**
  * @param string $source
  *
  * @return IAnnotationReflection
  */
 public static function build($source)
 {
     $annotationReflection = new self($source);
     foreach (StringUtils::split($source, '~\\n~s') as $line) {
         if (($annotation = StringUtils::match($line, '~@(?<annotation>[a-zA-Z0-9_-]+)(\\s+(?<text>.*))?~')) === null) {
             continue;
         }
         $annotationReflection->addAnnotation(new Annotation($annotation['annotation'], isset($annotation['text']) ? $annotation['text'] : null));
     }
     return $annotationReflection;
 }
コード例 #2
0
 public function isValid($value)
 {
     return StringUtils::match($value, '/(?=^.{1,254}$)(^(?:(?!\\d+\\.|-)[a-zA-Z0-9_\\-]{1,63}(?<!-)\\.)+(?:[a-zA-Z]{2,})$)/') !== null;
 }
コード例 #3
0
 public function isValid($value)
 {
     return StringUtils::match($value, '~^(([a-zA-Z]{1})|([a-zA-Z]{1}[a-zA-Z]{1})|([a-zA-Z]{1}[0-9]{1})|([0-9]{1}[a-zA-Z]{1})|([a-zA-Z0-9][a-zA-Z0-9-_]{1,61}[a-zA-Z0-9]))\\.([a-zA-Z]{2,6}|[a-zA-Z0-9-]{2,30}\\.[a-zA-Z]{2,3})$~') !== null;
 }
コード例 #4
0
 public function index()
 {
     /**
      * because we can run withou caching, this flag is needed
      */
     if ($this->built === true) {
         return $this;
     }
     /**
      * intentionally first line - built is done even if failature occures
      */
     $this->built = true;
     if ($this->cache->load('index') === true) {
         return $this;
     }
     $exclude = '~(' . implode(')|(', $this->excludeList) . ')~';
     $this->storage->truncate($schema = $this->createScannerFile()->schema());
     $this->storage->createSchema($schema);
     $this->storage->startTransaction(self::class);
     try {
         foreach ($this->pathList as $directory) {
             foreach ($this->createIterator($directory) as $path => $item) {
                 /**
                  * nice line, isn't it ;)?
                  */
                 if (!empty($this->excludeList) && StringUtils::match(($tmp = realpath($path)) ? $path = $tmp : $path, $exclude)) {
                     continue;
                 }
                 $finfo = new \finfo(FILEINFO_MIME);
                 $scannerFile = $this->createScannerFile();
                 $scannerFile->restore(['file' => FileUtils::normalize($item->getRealPath()), 'extension' => ($extension = $item->getExtension()) ? $extension : null, 'mime' => $finfo->file($path), 'size' => (int) $item->getSize(), 'stamp' => DateTimeUtils::create(), 'changed' => DateTimeUtils::from($item->getMTime())]);
                 $this->storage->save($scannerFile);
             }
         }
         $this->storage->commitTransaction(self::class);
         $this->cache->save('index', true);
     } catch (\Exception $e) {
         $this->storage->rollbackTransaction(self::class);
         throw $e;
     }
     return $this;
 }
コード例 #5
0
 /**
  * vrátí true/false, pokud je hodnota validní/nevalidní; slouží pro "měkké" ověření hodnoty
  *
  * @param mixed $value
  *
  * @return bool
  */
 public function isValid($value)
 {
     return StringUtils::match($value, $this->getOption('regexp')) !== null;
 }