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
188584
protected function createGenericCollection($data = [], $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;
    }
755978
public function loadMetadataForClass(\ReflectionClass $class)
    {
        $classMetadata = new MergeableClassMetadata($class->getName());

        foreach ($class->getProperties() as $reflectionProperty) {
            $propertyMetadata = new PropertyMetadata($class->getName(), $reflectionProperty->getName());

            /** @var $annotation \Zicht\Bundle\FileManagerBundle\Annotation\File */
            $annotation = $this->reader->getPropertyAnnotation(
                $reflectionProperty,
                'Zicht\Bundle\FileManagerBundle\Annotation\File'
            );
            if (null !== $annotation) {
                // a "@DefaultValue" annotation was found
                $propertyMetadata->fileManager = $annotation->settings;
            }

            $classMetadata->addPropertyMetadata($propertyMetadata);
        }

        return $classMetadata;
    }
801913
public function collectAnnotationMetadata($classes, $metadataCollection)
    {
        // Load annotation and parse classes
        new Injectable();
        new InjectArgument(['var' => 'type']);
        new Service(['value' => '']);

        $reader = new AnnotationReader();
        $resolver = new AnnotationResolver(
            new AnnotationClassResolver($reader),
            new AnnotationPropertyResolver($reader),
            new AnnotationMethodResolver($reader)
        );

        $annotationCollector = new AnnotationMetadataCollector($resolver);

        // Rewrite collection by entity name
        return $annotationCollector->collect($classes, $metadataCollection);
    }
388500
public static function hydrate(array $items, $class = null)
    {
        $items = array_map(function ($item) use ($class) {

            // Account for ID only
            if (gettype($item) === 'string') {
                $item = [
                    'id' => $item,
                ];
            }

            // Single class given
            if (gettype($class) === 'string') {
                return new $class($item);
            }

            // Map an array of classes
            if (gettype($class) === 'array') {

                if (isset($item['type']) && isset($class[$item['type']])) {
                    return new $class[$item['type']]($item);
                }

                return null;
            }

            return new static($item, static::getParentID());

        }, $items);

        return array_filter($items);
    }
880266
public function denormalize($data, $class, $format = null, array $context = [])
    {
        if (null === $this->serializer) {
            throw new BadMethodCallException('Please set a serializer before calling denormalize()!');
        }
        if (!\is_array($data)) {
            throw new InvalidArgumentException('Data expected to be an array, '.\gettype($data).' given.');
        }
        if ('[]' !== substr($class, -2)) {
            throw new InvalidArgumentException('Unsupported class: '.$class);
        }

        $serializer = $this->serializer;
        $class = substr($class, 0, -2);

        $builtinType = isset($context['key_type']) ? $context['key_type']->getBuiltinType() : null;
        foreach ($data as $key => $value) {
            if (null !== $builtinType && !('is_'.$builtinType)($key)) {
                throw new NotNormalizableValueException(sprintf('The type of the key "%s" must be "%s" ("%s" given).', $key, $builtinType, \gettype($key)));
            }

            $data[$key] = $serializer->denormalize($value, $class, $format, $context);
        }

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

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

        return $collection;
    }
33095
public static function fromProperty(
        string $class,
        string $property
    ): array
    {
        try {

            $property = new \ReflectionProperty($class, $property);
        }
        catch (\ReflectionException $e) {

            throw new Exception(
                "Property '{$class}::{$property}' not found.",
                Exception::PROPERTY_NOT_FOUND
            );
        }

        $docComment = $property->getDocComment();

        unset($property);

        if ($docComment === false) {

            return [];
        }

        return Parser::parseDocComment($docComment);
    }
35278
public static function getPropertyAnnotations($class, $property)
    {
        $annotationBag = Bridge\Loader::getInstance()->getPropertyAnnotations($class, str_replace('$', '', $property));
        $annotationBag = self::explodeNamespaces($annotationBag);

        return new ConfigObject($annotationBag);
    }
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;
    }
229649
protected function visitSimpleType(&$class, &$data, SimpleType $type, $name)
    {
        parent::visitSimpleType($class, $data, $type, $name);

        if ($restriction = $type->getRestriction()) {
            $parent = $restriction->getBase();
            if ($parent instanceof Type) {
                if (!isset($data["properties"]['__value'])) {
                    $data["properties"]['__value'] = [];
                }
                $this->loadValidatorType($data["properties"]['__value'], $type);
            }
        }
    }
1302694
private function implementGetIterator(ClassGenerator $class, Property $firstProperty)
    {
        $methodName = 'getIterator';
        $class->removeMethod($methodName);
        $class->addMethodFromGenerator(
            MethodGenerator::fromArray([
                'name' => $methodName,
                'parameters' => [],
                'visibility' => MethodGenerator::VISIBILITY_PUBLIC,
                'body' => sprintf(
                    'return new \\ArrayIterator(is_array($this->%1$s) ? $this->%1$s : []);',
                    $firstProperty->getName()
                ),
                'docblock' => DocBlockGeneratorFactory::fromArray([
                    'tags' => [
                        [
                            'name' => 'return',
                            'description' => '\\ArrayIterator'
                        ]
                    ]
                ])
            ])
        );
    }
1245095
public function collection($data, $transformer = null, $resourceKey = null): Collection
    {
        return new Collection($data, $transformer, $resourceKey);
    }
908250
public function createMany(array $data, $modelClass = null)
    {
        $models = [];
        foreach ($data as $item) {
            $models[] = $this->fromArray($item, $modelClass);
        }

        return $models;
    }
1060942
private function createTable(array $data, $class)
    {
        $table = new NodeElement();
        $table->openTag('table')
              ->setClass($class);

        $tbody = new NodeElement();
        $tbody->openTag('tbody');

        foreach ($data as $key => $value) {
            $row = $this->createRow($key, $value);
            $tbody->appendChild($row);
        }

        $tbody->closeTag();
        $table->appendChild($tbody);

        $table->closeTag();
        return $table;
    }
201575
private function handleJson($data, $class)
    {
        $data   = json_decode($data);
        $output = $this->fromStdObject($data, $class);

        return $output;
    }
786246
public function staticProperty($class, $property, $args = array()) {
		if(!class_exists($class))
			return null;
		if(!property_exists($class, $property))
			return null;
		
		$vars = get_class_vars($class);
		return $vars[$property];
	}
1259376
public function copyBulk($class, array $data, array $options = [])
    {
        $this->om->startFlushSuite();
        $copies = [];

        foreach ($data as $el) {
            //get the element
            $copies[] = $this->copy($el, $options);
        }

        $this->om->endFlushSuite();

        return $copies;
    }