/** * @param string $type * @return boolean */ public static function isValidPropertyTypeString($type) { if (false == is_string($type)) { return false; } try { $jmsTypeParser = new TypeParser(); $jmsTypeParser->parse($type); } catch (Exception $ex) { return false; } return true; }
public function __construct(Exclusion $exclusion = null, Relation $relation = null) { if (null !== $relation) { $this->name = $relation->getName(); $this->class = get_class($relation); $typeParser = new TypeParser(); if (null !== $relation->getEmbedded()) { $this->type = $typeParser->parse('Hateoas\\Model\\Embedded'); } elseif (null !== $relation->getHref()) { $this->type = $typeParser->parse('Hateoas\\Model\\Link'); } } if (null === $exclusion) { return; } $this->groups = $exclusion->getGroups(); $this->sinceVersion = $exclusion->getSinceVersion(); $this->untilVersion = $exclusion->getUntilVersion(); $this->maxDepth = $exclusion->getMaxDepth(); }
/** * Return only type name without params eg. Doctrine\Common\Collections\ArrayCollection<AppBundle\Entity\Post> result Doctrine\Common\Collections\ArrayCollection * * @return string * @throws Exception */ public function getTypeName() { $typeParser = new TypeParser(); $result = $typeParser->parse($this->getType()); if (false == array_key_exists("name", $result)) { throw new Exception("Invalid type parsing result"); } return $result["name"]; }