コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function validate()
 {
     $classname = Cname::toString($this->value);
     if (preg_match(self::REGEX, $classname) === 1) {
         $this->value = $classname;
         return true;
     }
     return false;
 }
コード例 #2
0
ファイル: ClassLocator.php プロジェクト: sndsgd/fs
 protected function getClassFromFile(\SplFileInfo $file) : string
 {
     if (!$file->isFile()) {
         return "";
     }
     $file = new \sndsgd\fs\entity\FileEntity($file);
     $extension = $file->getExtension();
     if (strtolower($extension) !== "php") {
         return "";
     }
     $contents = $file->read();
     if ($contents === false) {
         throw new \RuntimeException($file->getError());
     }
     return \sndsgd\Classname::fromContents($contents);
 }