public static function fromJson($json, Hydrator\HydratorInterface $hydrator = null) { if (is_string($json)) { $json = json_decode($json, true); } if (!is_array($json)) { throw new InvalidArgumentException('The provided specification must be a JSON-decodeable string, or an associative array'); } $description = new self(); if ($hydrator) { $description->setHydrator($hydrator); } $description->hydrate($json); return $description; }