private function isValidProperty(string $property, EntityInterface $meta) : bool { if ($meta->properties()->contains($property)) { return true; } $property = new Str($property); if (!$property->match('/[a-zA-Z]+(\\.[a-zA-Z]+)+/')) { return false; } $pieces = $property->split('.'); $piece = (string) $pieces->get(0); if (!$meta->children()->contains($piece)) { return false; } $child = $meta->children()->get($piece); $relationship = $child->relationship(); switch ($pieces->count()) { case 2: return $relationship->properties()->contains((string) $pieces->get(1)); case 3: $subPiece = (string) $pieces->get(1); if (!$relationship->childProperty() === $subPiece) { return false; } return $child->properties()->contains((string) $pieces->get(2)); } return false; }
public function __construct(string $language) { $language = new Str($language); if (!$language->match('~^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$~')) { throw new InvalidArgumentException(); } parent::__construct((string) $language); }
public static function fromString(string $type, Types $types) : TypeInterface { $type = new Str($type); if (!$type->match(self::PATTERN)) { throw new InvalidArgumentException(); } return new self((string) $type->getMatches(self::PATTERN)->get('format')); }
public function __construct(string $coding) { $coding = new Str($coding); if (!$coding->match('~^[\\w\\-]+$~')) { throw new InvalidArgumentException(); } parent::__construct((string) $coding); }
public function __construct(string $language, Quality $quality) { $language = new Str($language); if ((string) $language !== '*' && !$language->match('~^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$~')) { throw new InvalidArgumentException(); } $this->quality = $quality; parent::__construct((string) $language->append(';')->append((string) $quality)); }
public function __construct(string $coding, Quality $quality) { $coding = new Str($coding); if ((string) $coding !== '*' && !$coding->match('~^\\w+$~')) { throw new InvalidArgumentException(); } $this->quality = $quality; parent::__construct((string) $coding->append(';')->append((string) $quality)); }
public function __construct(string $charset, Quality $quality) { $charset = new Str($charset); if ((string) $charset !== '*' && !$charset->match('~^[a-zA-Z0-9\\-_:\\(\\)]+$~')) { throw new InvalidArgumentException(); } $this->quality = $quality; parent::__construct((string) $charset->append(';')->append((string) $quality)); }
public function __construct(string $scheme, string $parameter) { $scheme = new Str($scheme); if (!$scheme->match('~^\\w+$~')) { throw new InvalidArgumentException(); } $this->scheme = (string) $scheme; $this->parameter = $parameter; parent::__construct((string) $scheme->prepend('"')->append('" ')->append($parameter)->trim()); }