Cast array to entity

@param   array $matches The records

@return  array
499907
private function castToEntity($matches)
    {
        $entities = $this->entityRegistry->getEntityBuilder()->castToEntity($matches, $this->entityClass);

        return $entities;
    }
305016
protected function callback( $matches )
	{
//		print_m( $matches );
		$data	= array(
			'timestamp'		=> $matches[1],
			'datetime'		=> $matches[2],
			'remote_addr'	=> $matches[3],
			'request_uri'	=> $matches[4],
			'referer_uri'	=> $matches[5],
			'useragent'		=> $matches[6],
		);
		return serialize( $data );
	}
1318504
protected function literal(array $matches)
    {
        // hash from matches
        $hash = '[!' . __FUNCTION__ . '::read(' . \crc32($matches[1]) . ')!]';

        // save hash and value to literals array
        $this->literals[$hash] = $matches[1];

        // return hash value for replace
        return $hash;
    }
1120316
public function insertProtect(array $matches = [])
    {
        $gen = md5(mt_rand());

        /** @var ISession $s */
        $s = (new SessionInjector)->build();
        $s->csrf = array_merge(is_array($s->csrf) ? $s->csrf : [], [md5($gen)]);

        return $matches[1].'<input type="hidden" name="csrf" value="'.$gen.'" />'.$matches[2].$matches[3];
    }
565587
public function toArray()
    {
        $aReturn = array();

        foreach ($this->values as $sKey => $oEntity) {
            /* @var EntityInterface $oEntity */
            $aReturn[$sKey] = $oEntity->toArray();
        }

        return $aReturn;
    }
1230234
protected static function h(array $matches)
    {
        $level = strlen($matches[1]);
        return sprintf('<h%d>%s</h%d>', $level, trim($matches[2]), $level);
    }
877698
protected function indexEntities(array $aEntities)
    {
        $aIndexEntities = array();
        foreach ($aEntities as $oEntity) {
            $aIndexEntities[$oEntity->getCollectionIndex()] = $oEntity;
        }

        return $aIndexEntities;
    }
1275720
private function _decode_entity(array $match): string
    {
        // init
        $str = $match[0];

        // protect GET variables without XSS in URLs
        if (\preg_match_all("/[\?|&]?[\\p{L}0-9_\-\[\]]+\s*=\s*(?<wrapped>\"|\042|'|\047)(?<attr>[^\\1]*?)\\g{wrapped}/ui", $str, $matches)) {
            if (isset($matches['attr'])) {
                foreach ($matches['attr'] as $matchInner) {
                    $tmpAntiXss = clone $this;

                    $urlPartClean = $tmpAntiXss->xss_clean($matchInner);

                    if ($tmpAntiXss->isXssFound() === true) {
                        $this->_xss_found = true;

                        $str = \str_replace($matchInner, UTF8::rawurldecode($urlPartClean), $str);
                    }
                }
            }
        } else {
            $str = $this->_entity_decode(UTF8::rawurldecode($str));
        }

        return $str;
    }
930060
protected function _replaceParamsCallback($matches)
    {
        $key   = substr($matches[0], 1);
        $value = $this->_parameters[$key];

        if(!$value instanceof DatabaseQuerySelect) {
            $value = is_object($value) ? (string) $value : $value;
            $replacement = $this->getDriver()->quoteValue($value);
        }
        else $replacement = '('.$value.')';

        return is_array($value) ? '('.$replacement.')' : $replacement;
    }
390986
public function match(array $matches) {
        $params = explode(' ', $matches[1]);
        $paramsNum = count($params);
        $this->params[] = $params[0];

        if (1 == $paramsNum) {
            return sprintf($this->defaultRegx['char'], '+');
        }
        else if (2 == $paramsNum) {
            return sprintf($this->defaultRegx[$params[1]], '+');
        }
        else if (3 == $paramsNum) {
            return sprintf($this->defaultRegx[$params[1]], $params[2] > 0 ? '{' . $params[2] . '}' : '*');
        }
        else if (4 == $paramsNum) {
            return sprintf($this->defaultRegx[$params[1]], '{' . $params[2] . ',' . $params[3] . '}');
        }
    }
908699
protected function matchToKeys(array $matches)
    {
        $parameterNames = $this->parameterNames();

        if (count($parameterNames) == 0) {
            return array();
        }

        $parameters = array_intersect_key($matches, array_flip($parameterNames));

        return array_filter($parameters, function ($value)
        {
            return is_string($value) && (strlen($value) > 0);
        });
    }
836984
protected function parseDocReturn( $matches )
	{
		$return	= new ADT_PHP_Return( trim( $matches[1] ) );
		if( isset( $matches[2] ) )
			$return->setDescription( trim( $matches[2] ) );
		return $return;
	}
1226691
protected function getSelfMatchingValue(
        SimpleXMLElement $content,
        array $matches = [],
        ?string $alias = null
    ): array {
        $name = $matches[1];
        $key = $matches[2];
        $meta = $matches[3];

        $item = [];
        $uses = ($key == '@' ? $meta : "{$key},{$meta}");

        if (\is_null($alias)) {
            $alias = $name;
        }

        $collection = $this->getValue($content, \sprintf('%s[%s]', $name, $uses));

        foreach ((array) $collection as $collect) {
            $v = $collect[$meta];

            if ($key == '@') {
                $item[$alias][] = $v;
            } else {
                $item[$collect[$key]] = $v;
            }
        }

        return $item;
    }
465766
private function deserializeLabels(MatchQuestion $setQuestion, array $sets)
    {
        $labelsEntities = $setQuestion->getLabels()->toArray();

        foreach ($sets as $index => $setData) {
            $label = null;
            // Searches for an existing Label entity.
            foreach ($labelsEntities as $entityIndex => $entityLabel) {
                /** @var Label $entityLabel */
                if ($entityLabel->getUuid() === $setData['id']) {
                    $label = $entityLabel;
                    unset($labelsEntities[$entityIndex]);
                    break;
                }
            }

            $label = $label ?: new Label();
            $label->setUuid($setData['id']);

            $label->setOrder($index);

            // Deserialize firstSet content
            $label = $this->contentSerializer->deserialize($setData, $label);
            $setQuestion->addLabel($label);
        }

        // Remaining labels are no longer in the Question
        foreach ($labelsEntities as $labelToRemove) {
            $setQuestion->removeLabel($labelToRemove);
        }
    }
867781
protected function matchAsArray(array $attributes) : array
    {
        // Extract the attributes with the key of the relation,
        // which should be an array.
        $key = $this->relation;

        if (!array_key_exists($key, $attributes)) {
            $attributes[$key] = $this->asJson ? json_encode([]) : [];
        }

        if ($this->asJson) {
            $attributes[$key] = json_decode($attributes[$key], true);
        }

        if (!is_array($attributes[$key])) {
            throw new MappingException("'$key' column should be an array, actual :".$attributes[$key]);
        }

        $attributes[$key] = $this->buildEmbeddedCollection($attributes[$key]);

        return $attributes;
    }
140718
protected function decodeMatches(array $matches): string
    {
        if (1 === preg_match(static::REGEXP_PREVENTS_DECODING, $matches[0])) {
            return strtoupper($matches[0]);
        }

        return rawurldecode($matches[0]);
    }
1250679
public function _parseParams(array $matches)
    {
        $params = array();
        foreach ($matches as $k => $v) {
            if (is_numeric($k)) {
                if ($k === 0) {
                    continue;
                }
                $params[] = $v;
            } else {
                $params[$k] = $v;
            }
        }
        return new Set($params);
    }