@param array $data
@param string $class

@return PageInterface
762022
public static function makePage(array $data, $class = PageInterface::class)
    {
        $page = app($class);

        foreach ($data as $key => $value) {
            if ($key == 'badge') {
                if ($value instanceof BadgeInterface) {
                    $page->setBadge($value);
                    continue;
                } else if (!is_array($value)) {
                    $value = [$value];
                }

                call_user_func_array([$page, 'addBadge'], $value);
            } else if ($key != 'pages' and method_exists($page, $method = 'set'.ucfirst($key))) {
                $page->{$method}($value);
            }
        }

        if (isset($data['pages']) and is_array($data['pages'])) {
            foreach ($data['pages'] as $child) {
                $page->addPage($child);
            }
        }

        return $page;
    }
566606
protected function createPagination(array $data = null)
    {
        $pagination = new DatabasePagination();
        if ($data !== null) {
            $pagination->setData($data);
        }
        return $pagination;
    }
93338
public function setDataObjectClass($class)
    {
        if (!$class) {
            throw new InvalidArgumentException("Missing class provided");
        }

        if (!class_exists($class)) {
            throw new InvalidArgumentException("Non-existent classname \"{$class}\"");
        }

        if (!is_subclass_of($class, DataObject::class)) {
            throw new InvalidArgumentException("\"{$class}\" is not a DataObject subclass");
        }

        $this->dataObjectClass = $class;
        return $this;
    }
422247
public function bind(string $class, array $pointcuts) : BindInterface
    {
        $pointcuts = $this->getAnnotationPointcuts($pointcuts);
        $this->annotatedMethodsMatch(new \ReflectionClass($class), $pointcuts);

        return $this;
    }
438571
public static function hidrateModel($class, $data)
    {
        if ($data instanceof Model) {
            return $data;
        }

        if (!isset($data['pivot'])) {
            throw new \Exception("The 'pivot' attribute in the {$class} is hidden");
        }

        $model = new $class;
        $primaryKey = $model->getKeyName();

        $model->setAttribute($primaryKey, $data[$primaryKey])->setAttribute('name', $data['name']);
        $model->setRelation(
            'pivot',
            MorphPivot::fromRawAttributes($model, $data['pivot'], 'pivot_table')
        );

        return $model;
    }
1178657
public function make($class)
    {
        $controller = $this->container->make($class);
        $controller->setServer($this->makeServer());
        $controller->setView($this->makeView());
        $controller->setSession($this->makeSession());
        $controller->setUrlGenerator($this->makeUrlGenerator());

        return $controller;
    }
1056459
public static function create($class, EntityManager $entityManager)
    {
        $rc = new \ReflectionClass($class);
        $interface = 'Blast\CoreBundle\CodeGenerator\CodeGeneratorInterface';
        if (!$rc->implementsInterface($interface)) {
            throw new \RuntimeException("Class $class should implement $interface");
        }
        $codeGenerator = new $class();
        $codeGenerator::setEntityManager($entityManager);

        return $codeGenerator;
    }
913387
public static function create(array $data = [], ClientInterface $client = null)
    {

        return (new RequestService($client))
            ->setResourceClass(static::class)
            ->create($data);
    }
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);
    }
1053681
public function fromArray(
        array $data,
        $class,
        $document = null,
        $mode = self::UNSERIALIZE_PATCH
    ) {
        return $this->unserialize($data, $class, $document, $mode);
    }
1369965
public function fromArray(array $data, $modelClass = null)
    {
        if (null === $modelClass) {
            $modelClass = $this->getModelClass();
        }

        return $this->client->getHydrator()->hydrate($modelClass, $data);
    }
807117
public function make($class)
    {
        $action = $this->container->make($class);
        $action->setEvents($this->container->make('events'));

        return $action;
    }
511278
public function addDataArray(array $data)
    {
        $this->data = $data;
        $this->pager->setTotalRows(\count($this->data));

        return $this;
    }
832696
public function buildService($class)
    {
        $options = [
            'var_dir' => $this->configResolver->getParameter('var_dir'),
            'storage_dir' => $this->configResolver->getParameter('storage_dir'),
            'draft_images_dir' => $this->configResolver->getParameter('image.versioned_images_dir'),
            'published_images_dir' => $this->configResolver->getParameter('image.published_images_dir'),
        ];

        return new $class($this->publishedIOService, $this->draftIOService, $options);
    }
884367
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
    {
        if (
            isset($context['object_to_populate']) &&
            is_object($context['object_to_populate']) &&
            $class === get_class($context['object_to_populate'])
        ) {
            return $context['object_to_populate'];
        }

        $format = null;
        if (isset($context['format'])) {
            $format = $context['format'];
        }

        $constructor = $reflectionClass->getConstructor();
        if (!$constructor) {
            return new $class();
        }

        $constructorParameters = $constructor->getParameters();

        $params = array();
        foreach ($constructorParameters as $constructorParameter) {
            $paramName = $constructorParameter->name;
            $key = $this->nameConverter ? $this->nameConverter->normalize($paramName) : $paramName;

            $allowed = $allowedAttributes === false || in_array($paramName, $allowedAttributes);
            $ignored = in_array($paramName, $this->ignoredAttributes);

            if (!$allowed || $ignored) {
                continue;
            }

            $missing = !isset($data[$key]) && !array_key_exists($key, $data);
            $variadic = method_exists($constructorParameter, 'isVariadic') && $constructorParameter->isVariadic();

            if ($variadic && !$missing && !is_array($data[$paramName])) {
                $message = 'Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.';
                throw new RuntimeException(sprintf($message, $class, $constructorParameter->name));
            }

            if ($variadic && !$missing) {
                $params = array_merge($params, $data[$paramName]);

                continue;
            }

            if ($missing && !$variadic && !$constructorParameter->isDefaultValueAvailable()) {
                $message = 'Cannot create an instance of %s from serialized data because its constructor requires parameter "%s" to be present.';
                throw new RuntimeException(sprintf($message, $class, $constructorParameter->name));
            }

            if ($missing && $constructorParameter->isDefaultValueAvailable()) {
                $params[] = $constructorParameter->getDefaultValue();

                continue;
            }

            if (!$missing) {
                $params[] = $this->denormalizeProperty($data[$key], $class, $key, $format, $context);

                unset($data[$key]);
            }
        }

        return $reflectionClass->newInstanceArgs($params);
    }
464107
public function addClass($class)
    {
        if (!is_array($class)) {
            $class = preg_split('/\s+/', $class, null, PREG_SPLIT_NO_EMPTY);
        }
        $curClass = preg_split('/\s+/', $this->getAttribute('class'),
                               null, PREG_SPLIT_NO_EMPTY);
        foreach ($class as $c) {
            if (!in_array($c, $curClass)) {
                $curClass[] = $c;
            }
        }
        $this->setAttribute('class', implode(' ', $curClass));

        return $this;
    }
829416
public function newInstance($class)
    {
        /** @var $form AbstractForm */
        $form = new $class;
        $form->setBaseDependencies(new Builder, new FilterFactory, new HelperLocatorFactory);
        $form->postConstruct();

        return $form;
    }