/** * {@inheritdoc} */ public function createCollection(array $data = []) { $collection = new GenericCollection(); foreach ($data as $item) { $collection->add(null, $this->create($item)); } return $collection; }
/** * {@inheritdoc} */ public function createCollection(array $data = []) { $collection = new GenericCollection(); if (array_key_exists('networks', $data)) { $data = $data['networks']; } foreach ($data as $item) { $collection->add(null, $this->create($item)); } return $collection; }
/** * @param array $data * @param $class * @return GenericCollection */ public function createCollection(array $data, $class) { if (is_object($class)) { $class = get_class($class); } $collection = new GenericCollection(); $objectHydrator = new ObjectHydrator(); foreach ($data as $item) { $collection->add(null, $objectHydrator->hydrate(new $class(), $item)); } return $collection; }
/** * Create a generic collection of data and map it on the class by it's static parameter $properties * * @param array $data * @param $class * @return GenericCollection */ protected function createGenericCollection($data = array(), $class) { if (is_object($class)) { $class = get_class($class); } $collection = new GenericCollection(); if (null === $data) { return $collection; } foreach ($data as $item) { $collection->add(null, $this->hydrate(new $class(), $item)); } return $collection; }
/** * {@inheritdoc} */ public function createCollection(array $data = []) { if (array_key_exists('certifications', $data)) { $data = $data['certifications']; } $collection = new GenericCollection(); foreach ($data as $country => $certifications) { $certification = new Certification(); $certification->setCountry($country); foreach ($certifications as $countryCertification) { $object = $this->create($countryCertification); $certification->getCertifications()->add(null, $object); } $collection->add(null, $certification); } return $collection; }
/** * {@inheritdoc} */ public function createCollection(array $data = []) { $collection = new GenericCollection(); $collection->add(null, $this->create($data)); return $collection; }
/** * Create an generic collection of an array that consists out of a mix of movies and tv shows * * @param array $data * @return GenericCollection */ protected function createGenericCollectionFromMediaTypes($data = []) { $movieFactory = new MovieFactory($this->getHttpClient()); $tvFactory = new TvFactory($this->getHttpClient()); $collection = new GenericCollection(); foreach ($data as $item) { switch ($item['media_type']) { case "movie": $collection->add(null, $movieFactory->create($item)); break; case "tv": $collection->add(null, $tvFactory->create($item)); break; default: throw new \RuntimeException('Unknown media type "%s"', $item['media_type']); } } return $collection; }