/** * @param array $array * @return $this */ public static function fromArray(array $array) { if (isset($array["type"]) === false || isset($array["id"]) === false) { return null; } $resourceIdentifier = new self(); $resourceIdentifier->setType($array["type"]); $resourceIdentifier->setId($array["id"]); if (isset($array["meta"]) === true) { $resourceIdentifier->setMeta($array["meta"]); } return $resourceIdentifier; }
/** * @param array $array * @param ExceptionFactoryInterface $exceptionFactory * @return $this * @throw \Exception */ public static function fromArray(array $array, ExceptionFactoryInterface $exceptionFactory) { if (isset($array["type"]) === false) { throw $exceptionFactory->createResourceIdentifierTypeMissing($array); } if (isset($array["id"]) === false) { throw $exceptionFactory->createResourceIdentifierIdMissing($array); } $resourceIdentifier = new self(); $resourceIdentifier->setType($array["type"]); $resourceIdentifier->setId($array["id"]); if (isset($array["meta"]) === true) { $resourceIdentifier->setMeta($array["meta"]); } return $resourceIdentifier; }