Create a generic collection of data and map it on the class by it's static parameter $properties

@param  array             $data
@param  AbstractModel     $class
@param  GenericCollection $collection
@return GenericCollection
764856
protected function createCustomCollection($data = [], $class, $collection)
    {
        if (is_object($class)) {
            $class = get_class($class);
        }

        if (null === $data) {
            return $collection;
        }

        foreach ($data as $item) {
            $collection->add(null, $this->hydrate(new $class(), $item));
        }

        return $collection;
    }
301900
public function collectionProperties()
    {
        $props = $this->properties();

        foreach ($props as $propertyIdent => $property) {
            $propertyMetadata = $props[$propertyIdent];

            $p = $this->propertyFactory()->create($propertyMetadata['type']);
            $p->setIdent($propertyIdent);
            $p->setData($propertyMetadata);

            $options = $this->viewOptions($propertyIdent);
            $classes = $this->parsePropertyCellClasses($p);

            if (isset($options['label'])) {
                $label = $this->translator()->translate($options['label']);
            } else {
                $label = strval($p->label());
            }

            $column = [
                'label' => trim($label)
            ];

            if (!isset($column['attr'])) {
                $column['attr'] = [];
            }

            if (isset($options['attr'])) {
                $column['attr'] = array_merge($column['attr'], $options['attr']);
            }

            if (isset($classes)) {
                if (isset($column['attr']['class'])) {
                    if (is_string($classes)) {
                        $classes = explode(' ', $column['attr']['class']);
                    }

                    if (is_string($column['attr']['class'])) {
                        $column['attr']['class'] = explode(' ', $column['attr']['class']);
                    }

                    $column['attr']['class'] = array_unique(array_merge($column['attr']['class'], $classes));
                } else {
                    $column['attr']['class'] = $classes;
                }

                unset($classes);
            }

            $column['attr'] = html_build_attributes($column['attr']);

            yield $column;
        }
    }
564694
@SuppressWarnings("all")
    public static <T> List<T> toTypedList(Object data, Class<T> type) {
        List<T> listResult = new ArrayList<>();
        if (data == null) {
            return listResult;
        }
        if (data instanceof Collection) {
            Collection collection = (Collection) data;
            for (Object o : collection) {
                listResult.add(Reflection.toType(o, type));
            }
            return listResult;
        }
        if (data.getClass().isArray()) {
            for (Object o : ArrayUtil.toObjectArray(data)) {
                listResult.add(Reflection.toType(o, type));
            }
            return listResult;
        }
        listResult.add(Reflection.toType(data, type));
        return listResult;
    }
742082
@SuppressWarnings({ "unchecked", "rawtypes" })
    public <T extends AbstractSchemaProperty> Set<T> get(final Class<T> clazz) {
        return (Set<T>) properties.get(clazz);
    }
1039084
protected function makeNestedDataObject(string $class, $data, $key): DataObjectInterface
    {
        $data = ($data instanceof Arrayable) ? $data->toArray() : $data;

        if ( ! is_array($data)) {

            throw new UnexpectedValueException(
                "Cannot instantiate data object '{$class}' with non-array data for key '{$key}'"
                . (is_scalar($data) || is_object($data) && method_exists($data, '__toString')
                    ?   ' (data: ' . (string) $data . ')'
                    :   null)
            );
        }

        /** @var DataObjectInterface $data */
        return new $class($data);
    }
55344
public function createResultCollection($data = [], $method = 'create')
    {
        $collection = new ResultCollection();

        if (null === $data) {
            return $collection;
        }

        if (array_key_exists('page', $data)) {
            $collection->setPage($data['page']);
        }

        if (array_key_exists('total_pages', $data)) {
            $collection->setTotalPages($data['total_pages']);
        }

        if (array_key_exists('total_results', $data)) {
            $collection->setTotalResults($data['total_results']);
        }

        if (array_key_exists('results', $data)) {
            $data = $data['results'];
        }

        foreach ($data as $item) {
            $collection->add(null, $this->$method($item));
        }

        return $collection;
    }
1094280
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;
    }
528727
public function createCollection(array $data = [], $person = null, $collection = null)
    {
        if (!$collection) {
            $collection = new People();
        }

        if (array_key_exists('results', $data)) {
            $data = $data['results'];
        }

        if (is_object($person)) {
            $class = get_class($person);
        } else {
            $class = '\Tmdb\Model\Person';
        }

        foreach ($data as $item) {
            $collection->add(null, $this->create($item, new $class()));
        }

        return $collection;
    }
894804
protected function generateProperty($propertyName, array $data, $directory, array $dataTypes)
    {
        $property = $this->getPropertyClassName($propertyName);

        $class = new PhpClass();
        $class
            ->setQualifiedName('SecIT\\SchemaOrg\\Mapping\\Property\\'.$property)
            ->setParentClassName('AbstractProperty')
            ->setDescription($property.' class.'."\n\n".'@method '.$property.' setValue($value)')
            ->setMethod(PhpMethod::create('getSchemaUrl')
                ->setDescription('Get schema URL.')
                ->setType('string')
                ->setBody('return \''.$data['url'].'\';')
            )
        ;

        if ($this->backwardCompatibility && !$this->php7ClassNames) {
            $this->php7ClassNames = true;
            $deprecatedMessage = 'This class is deprecated and will be removed in release 3.4. Use SecIT\\SchemaOrg\\Mapping\\Property\\'.$this->getPropertyClassName($propertyName).' instead.';
            $this->php7ClassNames = false;
            $class->setDescription($class->getDescription()."\n\n".'@deprecated '.$deprecatedMessage);
        }

        $instanceCheckConditions = [];
        foreach ($data['ranges'] as $range) {
            if (isset($dataTypes[$range])) {
                $class->addUseStatement('SecIT\\SchemaOrg\\Mapping\\DataType');
                $instanceCheckConditions[] = '$value instanceof DataType\\'.$this->getDataTypeClassName($range);
            } else {
                $class->addUseStatement('SecIT\\SchemaOrg\\Mapping\\Type');
                $instanceCheckConditions[] = '$value instanceof Type\\'.$this->getTypeClassName($range);
            }
        }

        // if no conditions than always return true
        if (!$instanceCheckConditions) {
            $instanceCheckConditions[] = 'true';
        }

        $class
            ->setMethod(PhpMethod::create('isValueValid')
                ->setDescription('Check is value valid.')
                ->addParameter(PhpParameter::create('value')
                    ->setType('string')
                )
                ->setType('bool')
                ->setBody('return '.implode(' || ', $instanceCheckConditions).';')
            )
        ;

        $generator = new CodeGenerator();
        $code = $generator->generate($class);

        file_put_contents($directory.$property.'.php', "<?php\n\n".$code);
    }
378243
public function createImageCollection(array $data = [])
    {
        $collection = new Images();

        foreach ($data as $format => $formatCollection) {

            if (!is_array($formatCollection)) {
                continue;
            }

            foreach ($formatCollection as $item) {
                if (array_key_exists($format, Image::$formats)) {
                    $item = $this->create($item, $format);

                    $collection->addImage($item);
                }
            }
        }

        return $collection;
    }
320178
public function createCollection(array $data = [])
    {
        $collection = new Images();

        foreach ($data as $item) {
            $collection->add(null, $this->create($item));
        }

        return $collection;
    }
474254
public function create(string $resourceClass, array $options = []): PropertyNameCollection
    {
        $properties = $this->propertyInfo->getProperties($resourceClass, $options);
        if (null === $properties) {
            throw new RuntimeException(sprintf('There is no PropertyInfo extractor supporting the class "%s".', $resourceClass));
        }

        return new PropertyNameCollection($properties);
    }
1010452
public function create( $type, array $properties = [ ] ) {

		$type = (string) $type;

		if ( isset( $this->classes[ $type ] ) ) {
			$class = $this->classes[ $type ];

			return new $class( $properties );
		} else if ( class_exists( $type ) ) {
			$class = new $type( $properties );
			if ( $class instanceof FilterInterface ) {

				return $class;
			}
		}

		throw new Exception\InvalidArgumentException(
			sprintf(
				'The given class <code>%s</code> does not exists.',
				$type
			)
		);

	}
105234
public function setProperties(array $properties) : DataSet
    {
        $this->properties = [];

        foreach ($properties as $key => $value) {
            $this->addProperty($key, $value);
        }

        return $this;
    }
183162
protected function denormalizeProperty($data, $class, $name, $format = null, array $context = array())
    {
        if (!$this->propertyInfoExtractor) {
            return $data;
        }

        /** @var Type[] $types */
        $types = (array) $this->propertyInfoExtractor->getTypes($class, $name);
        $_class = null;
        $_class = array_reduce(
            $types,
            function($class, Type $type) {
                return $class ?: $type->getClassName();
            },
            $_class
        );

        if ($data === null and $_class === null) {
            return $data;
        }

        if (!$this->serializer instanceof DenormalizerInterface) {
            $message = 'Cannot denormalize attribute "%s" because injected serializer is not a denormalizer';
            throw new RuntimeException(sprintf($message, $name));
        }

        if ($_class === null
            or !$this->serializer->supportsDenormalization($data, $_class, $format, $context)) {
            return $data;
        }

        return $this->serializer->denormalize($data, $_class, $format, $context);
    }
1354454
protected function set($property, AbstractModel $model)
    {
        $key = $model->getCompositeKey();
        $this->{$property}[$key] = $model;

        if ('models' === $property) {
            $keys = array_flip($this->modelKeyMap);
            if (!isset($keys[$key])) {
                $this->modelKeyMap[] = $key;
                $this->totalCount++;
            }
        }
        return $this;
    }
795657
private function loadTranslatableMetadata(\ReflectionClass $class) {
        $classMetadata = new TranslatableMetadata($class->name);

        foreach ($class->getProperties() as $property) {
            if ($property->class !== $class->name) {
                continue;
            }

            $propertyMetadata = new PropertyMetadata($class->name, $property->getName());

            if ($this->reader->getPropertyAnnotation($property, 'Prezent\\Doctrine\\Translatable\\Annotation\\CurrentLocale')) {
                $classMetadata->currentLocale = $propertyMetadata;
                $classMetadata->addPropertyMetadata($propertyMetadata);
            }
            
            if ($this->reader->getPropertyAnnotation($property, 'Prezent\\Doctrine\\Translatable\\Annotation\\FallbackLocale')) {
                $classMetadata->fallbackLocale = $propertyMetadata;
                $classMetadata->addPropertyMetadata($propertyMetadata);
            }
            
            if ($annot = $this->reader->getPropertyAnnotation($property, 'Prezent\\Doctrine\\Translatable\\Annotation\\Translations')) {
                $classMetadata->targetEntity = $annot->targetEntity;
                $classMetadata->translations = $propertyMetadata;
                $classMetadata->addPropertyMetadata($propertyMetadata);
            }
        }

        return $classMetadata;
    }