コード例 #1
0
ファイル: Url.php プロジェクト: bogdananton/php-vcs-control
 public function __construct($value)
 {
     if (filter_var($value, FILTER_VALIDATE_URL) === false) {
         throw new \InvalidArgumentException('Invalid url format.');
     }
     parent::__construct($value);
 }
コード例 #2
0
 public static function get($native, $type = self::STRING)
 {
     switch ($type) {
         case self::FILEPATH:
             return Filepath::fromNative($native);
             break;
         case self::STRING:
             return StringLiteral::fromNative($native);
             break;
         case self::URL:
             return Url::fromNative($native);
             break;
         default:
             $oReflection = new \ReflectionObject(new self());
             $allowedTypes = array_keys($oReflection->getConstants());
             throw new InvalidNativeArgumentException($type, $allowedTypes);
             break;
     }
 }