@param object|string $entity
@param array        $array

@return object
422046
public static function fromArray($entity, array $array)
    {
        if (is_string($entity)) {
            $entity = InstanceHelper::createInstanceWithoutConstructor($entity);
        }

        $reflectionPropertyList = InstanceHelper::getReflectionProperties($entity);
        ClassHelper::setReflectionPropertiesAccessible($reflectionPropertyList);

        /** @var ReflectionProperty $reflectionProperty */
        foreach ($reflectionPropertyList as $reflectionProperty) {
            $propertyName = $reflectionProperty->getName();
            if (array_key_exists($propertyName, $array)) {
                $reflectionProperty->setValue($entity, $array[$propertyName]);
            }
        }

        return $entity;
    }
161952
protected function doCreateObject(array $array)
    {
        $orderItem = new WishListItem($array);
        if (isset($array['products']) && $product = reset($array['products'])) {
            $productMapper = new ProductsMapper();

            if (isset($array['images'])) {
                $product['images'] = $array['images'];
            }

            $orderItem->product = $productMapper->createObject($product);
        }

        return $orderItem;
    }
701576
public static function filter(array $array, $method)
    {
        //if the method is valid
        if (gettype($method)==='object') {
            $out = [];
            foreach ($array as $key=>$value) {
                //true if key and value satisfy the method
                if (call_user_func_array($method, [$key,$value])) {
                    $out[$key] = $value;
                }
            }
            return $out;
        } else {
            //send error message if the given method is not valid
            system::add_error('ary::filter()', 'missing_function', 'second parameter must be a function object');
        }
    }
851237
protected function entityToArray($entity, HydratorInterface $hydrator = null)
    {
        if (is_array($entity)) {
            return $entity; // cut down on duplicate code
        } elseif (is_object($entity)) {
            if (!$hydrator) {
                $hydrator = $this->getHydrator();
            }
            return $hydrator->extract($entity);
        }
        throw new Exception\InvalidArgumentException('Entity passed to db mapper should be an array or object.');
    }
529816
public static function createFromArray(array $array) : Reader
    {
        $classname = \get_called_class(); // para permitir abstração
        $instance = new $classname;
        $instance->type   = 'array';
        $instance->buffer = $array;

        return $instance;
    }
743538
public function copyToArray(array &$array)
    {
        $array['serviceName']                                 = $this->serviceName;
        $array['apiKey']                                      = $this->apiKey;
        $array['apiSecret']                                   = $this->apiSecret;
        $array['issuer']                                      = $this->issuer;
        $array['authorizationEndpoint']                       = $this->authorizationEndpoint;
        $array['tokenEndpoint']                               = $this->tokenEndpoint;
        $array['revocationEndpoint']                          = $this->revocationEndpoint;
        $array['supportedRevocationAuthMethods']              = LanguageUtility::convertArrayToStringArray($this->supportedRevocationAuthMethods);
        $array['userInfoEndpoint']                            = $this->userInfoEndpoint;
        $array['jwksUri']                                     = $this->jwksUri;
        $array['jwks']                                        = $this->jwks;
        $array['registrationEndpoint']                        = $this->registrationEndpoint;
        $array['supportedScopes']                             = LanguageUtility::convertArrayOfArrayCopyableToArray($this->supportedScopes);
        $array['supportedResponseTypes']                      = LanguageUtility::convertArrayToStringArray($this->supportedResponseTypes);
        $array['supportedGrantTypes']                         = LanguageUtility::convertArrayToStringArray($this->supportedGrantTypes);
        $array['supportedAcrs']                               = $this->supportedAcrs;
        $array['supportedTokenAuthMethods']                   = LanguageUtility::convertArrayToStringArray($this->supportedTokenAuthMethods);
        $array['supportedDisplays']                           = LanguageUtility::convertArrayToStringArray($this->supportedDisplays);
        $array['supportedClaimTypes']                         = LanguageUtility::convertArrayToStringArray($this->supportedClaimTypes);
        $array['supportedClaims']                             = $this->supportedClaims;
        $array['serviceDocumentation']                        = $this->serviceDocumentation;
        $array['supportedClaimLocales']                       = $this->supportedClaimLocales;
        $array['supportedUiLocales']                          = $this->supportedUiLocales;
        $array['policyUri']                                   = $this->policyUri;
        $array['tosUri']                                      = $this->tosUri;
        $array['description']                                 = $this->description;
        $array['accessTokenType']                             = $this->accessTokenType;
        $array['accessTokenDuration']                         = $this->accessTokenDuration;
        $array['refreshTokenDuration']                        = $this->refreshTokenDuration;
        $array['idTokenDuration']                             = $this->idTokenDuration;
        $array['authorizationResponseDuration']               = $this->authorizationResponseDuration;
        $array['authenticationCallbackEndpoint']              = $this->authenticationCallbackEndpoint;
        $array['authenticationCallbackApiKey']                = $this->authenticationCallbackApiKey;
        $array['authenticationCallbackApiSecret']             = $this->authenticationCallbackApiSecret;
        $array['supportedSnses']                              = LanguageUtility::convertArrayToStringArray($this->supportedSnses);
        $array['snsCredentials']                              = LanguageUtility::convertArrayOfArrayCopyableToArray($this->snsCredentials);
        $array['createdAt']                                   = LanguageUtility::orZero($this->createdAt);
        $array['modifiedAt']                                  = LanguageUtility::orZero($this->modifiedAt);
        $array['developerAuthenticationCallbackEndpoint']     = $this->developerAuthenticationCallbackEndpoint;
        $array['developerAuthenticationCallbackApiKey']       = $this->developerAuthenticationCallbackApiKey;
        $array['developerAuthenticationCallbackApiSecret']    = $this->developerAuthenticationCallbackApiSecret;
        $array['supportedDeveloperSnses']                     = LanguageUtility::convertArrayToStringArray($this->supportedDeveloperSnses);
        $array['developerSnsCredentials']                     = LanguageUtility::convertArrayOfArrayCopyableToArray($this->developerSnsCredentials);
        $array['clientsPerDeveloper']                         = $this->clientsPerDeveloper;
        $array['directAuthorizationEndpointEnabled']          = $this->directAuthorizationEndpointEnabled;
        $array['directTokenEndpointEnabled']                  = $this->directTokenEndpointEnabled;
        $array['directRevocationEndpointEnabled']             = $this->directRevocationEndpointEnabled;
        $array['directUserInfoEndpointEnabled']               = $this->directUserInfoEndpointEnabled;
        $array['directJwksEndpointEnabled']                   = $this->directJwksEndpointEnabled;
        $array['directIntrospectionEndpointEnabled']          = $this->directIntrospectionEndpointEnabled;
        $array['singleAccessTokenPerSubject']                 = $this->singleAccessTokenPerSubject;
        $array['pkceRequired']                                = $this->pkceRequired;
        $array['refreshTokenKept']                            = $this->refreshTokenKept;
        $array['errorDescriptionOmitted']                     = $this->errorDescriptionOmitted;
        $array['errorUriOmitted']                             = $this->errorUriOmitted;
        $array['clientIdAliasEnabled']                        = $this->clientIdAliasEnabled;
        $array['supportedServiceProfiles']                    = LanguageUtility::convertArrayToStringArray($this->supportedServiceProfiles);
        $array['tlsClientCertificateBoundAccessTokens']       = $this->tlsClientCertificateBoundAccessTokens;
        $array['mutualTlsValidatePkiCertChain']               = $this->mutualTlsValidatePkiCertChain;
        $array['introspectionEndpoint']                       = $this->introspectionEndpoint;
        $array['supportedIntrospectionAuthMethods']           = LanguageUtility::convertArrayToStringArray($this->supportedIntrospectionAuthMethods);
        $array['trustedRootCertificates']                     = $this->trustedRootCertificates;
        $array['authorizationSignatureKeyId']                 = $this->authorizationSignatureKeyId;
        $array['idTokenSignatureKeyId']                       = $this->idTokenSignatureKeyId;
        $array['userInfoSignatureKeyId']                      = $this->userInfoSignatureKeyId;
    }
1032295
public function copyFromArray(array &$array)
    {
        parent::copyFromArray($array);

        // action
        $this->setAction(
            TokenAction::valueOf(
                LanguageUtility::getFromArray('action', $array)));

        // responseContent
        $this->setResponseContent(
            LanguageUtility::getFromArray('responseContent', $array));

        // username
        $this->setUsername(
            LanguageUtility::getFromArray('username', $array));

        // password
        $this->setPassword(
            LanguageUtility::getFromArray('password', $array));

        // ticket
        $this->setTicket(
            LanguageUtility::getFromArray('ticket', $array));

        // accessToken
        $this->setAccessToken(
            LanguageUtility::getFromArray('accessToken', $array));

        // accessTokenExpiresAt
        $this->setAccessTokenExpiresAt(
            LanguageUtility::getFromArray('accessTokenExpiresAt', $array));

        // accessTokenDuration
        $this->setAccessTokenDuration(
            LanguageUtility::getFromArray('accessTokenDuration', $array));

        // refreshToken
        $this->setRefreshToken(
            LanguageUtility::getFromArray('refreshToken', $array));

        // refreshTokenExpiresAt
        $this->setRefreshTokenExpiresAt(
            LanguageUtility::getFromArray('refreshTokenExpiresAt', $array));

        // refreshTokenDuration
        $this->setRefreshTokenDuration(
            LanguageUtility::getFromArray('refreshTokenDuration', $array));

        // idToken
        $this->setIdToken(
            LanguageUtility::getFromArray('idToken', $array));

        // grantType
        $this->setGrantType(
            GrantType::valueOf(
                LanguageUtility::getFromArray('grantType', $array)));

        // clientId
        $this->setClientId(
            LanguageUtility::getFromArray('clientId', $array));

        // clientIdAlias
        $this->setClientIdAlias(
            LanguageUtility::getFromArray('clientIdAlias', $array));

        // clientIdAliasUsed
        $this->setClientIdAliasUsed(
            LanguageUtility::getFromArrayAsBoolean('clientIdAlias', $array));

        // subject
        $this->setSubject(
            LanguageUtility::getFromArray('subject', $array));

        // scopes
        $this->setScopes(
            LanguageUtility::getFromArray('scopes', $array));

        // properties
        $properties = LanguageUtility::getFromArray('properties', $array);
        $this->setProperties(
            LanguageUtility::convertArrayToArrayOfArrayCopyable(
                $properties, __NAMESPACE__ . '\Property'));
    }
664415
public function bind($entity, array $data)
    {
        $meta = $this->getMeta();

        foreach ($data as $key => $value) {
            if (is_null($value)) {
                continue;
            }

            if (array_key_exists($key, $meta->fields)) {
                $property            = $meta->propertyName($key);
                $entity->{$property} = $value;
            }
        }

        $this->unitOfWork->getEntityRegistry()->getEntityBuilder()->resolve($entity);
    }
320456
public static function createFromArray(array $array): self
    {
        $config = new self(
            ($array['language'] ?? null),
            ($array['store_searchable_metadata'] ?? true)
        );

        $config->synonyms = array_map(function (array $synonym) {
            return Synonym::createFromArray($synonym);
        }, $array['synonyms'] ?? []);
        $config->shards = (int) ($array['shards'] ?? self::DEFAULT_SHARDS);
        $config->replicas = (int) ($array['replicas'] ?? self::DEFAULT_REPLICAS);

        return $config;
    }
70266
public function toSerializableArray($entity)
    {
        $data = array_intersect_key($entity->getData(), $entity->getEntityDescription()->getAttributes());

        return $data;
    }
18642
public static function pluck(array $array, $key)
    {
        return array_map(
            function ($item) use ($key) {
                return is_object($item) ? $item->$key : $item[$key];
            },
            $array
        );
    }
220949
public function materialize(array $data, $entity)
    {
        //use a entity proxy to delay loading the related entity
        if ($this->_cardinality == 1) {
            $config = array();
            $config['relationship'] = $this;
            $config['value'] = $entity;
            $config['property'] = $this->_child_key;
            $config['service_identifier'] = $this->getChildRepository()->getDescription()->getEntityIdentifier();

            return new AnDomainEntityProxy(new AnConfig($config));
        } else {
            return $this->getSet($entity);
        }
    }
1362876
public static function getObjectWithKeyAndValue(array $array, $key, $value)
    {
        foreach ($array as $object) {
            if (is_array($object) && array_key_exists($key, $object) && $object[$key] === $value) {
                return $object;
            }
        }

        return null;
    }
406070
public function fillFromArray(array $array)
    {
        $this->resetCollection();
        foreach ($array as $one_array) {

            // Important to have every time new Object,
            // !!! Not copy of last existing version with values
            $instance = clone $this->getInstance();

            // make reset attributes
            if ($instance instanceof \Phunc\CollectionInstanceInterface) {
                $instance->reset();
            }

            $this->add(
                $instance->fillFromArray($one_array)
            );
        }
        return $this;
    }
756787
public function hydrate(array $data, $entity)
    {
        $this->hydrateEntityProperties($entity, $data);
        
        $repository = $this->getRepository();
        $repository->dispatchEvent(ORMEvents::onEntityLoad, new EntityLifecycleEvent($repository, $entity));
        
        return $entity;
    }
741958
public static function get($array, $key, $default = null)
    {
        return is_array($key)
            ? static::getArray($array, $key, $default)
            : parent::get($array, $key, $default);
    }
539381
public final function entity(array $data = []): Entity
    {
        $entity = new Entity($this, $data);
        if (method_exists($this, 'onEntity')) {
            $this->onEntity($entity);
        }

        return $entity;
    }