<commit_before><?php

namespace Oro\Bundle\ApiBundle\Provider;

use Oro\Component\ChainProcessor\ActionProcessorInterface;
use Oro\Bundle\ApiBundle\Config\EntityDefinitionConfig;
use Oro\Bundle\ApiBundle\Metadata\EntityMetadata;
use Oro\Bundle\ApiBundle\Metadata\MetadataExtraInterface;
use Oro\Bundle\ApiBundle\Processor\GetMetadata\MetadataContext;
use Oro\Bundle\ApiBundle\Request\RequestType;

class MetadataProvider
{
    /** @var ActionProcessorInterface */
    protected $processor;

    /** @var array */
    protected $cache = [];

    /**
     * @param ActionProcessorInterface $processor
     */
    public function __construct(ActionProcessorInterface $processor)
    {
        $this->processor = $processor;
    }

    /**
     * Gets metadata for the given version of an entity.
     *
     * @param string                      $className   The FQCN of an entity
     * @param string                      $version     The version of a config
     * @param RequestType                 $requestType The request type, for example "rest", "soap", etc.
     * @param MetadataExtraInterface[]    $extras      Requests for additional metadata information
     * @param EntityDefinitionConfig|null $config      The configuration of an entity
     *
     * @return EntityMetadata|null
     */
    public function getMetadata(
        $className,
        $version,
        RequestType $requestType,
        array $extras = [],
        EntityDefinitionConfig $config = null
    ) {
        if (empty($className)) {
            throw new \InvalidArgumentException('$className must not be empty.');
        }

        $configKey = $config
            ? $config->getKey()
            : 'no_config';
        if (!$configKey) {
            return $this->loadMetadata($className, $version, $requestType, $extras, $config);
        }
        
        $cacheKey = $this->buildCacheKey($className, $version, $requestType, $extras, $configKey);
        if (array_key_exists($cacheKey, $this->cache)) {
            return clone $this->cache[$cacheKey];
        }

        $metadata = $this->loadMetadata($className, $version, $requestType, $extras, $config);
        $this->cache[$cacheKey] = $metadata;

        return null !== $metadata
            ? clone $metadata
            : null;<commit_msg>OEE-839: Implement API for Outlook Add-in automatic updates. Fix CS<commit_after><?php

namespace Oro\Bundle\ApiBundle\Provider;

use Oro\Component\ChainProcessor\ActionProcessorInterface;
use Oro\Bundle\ApiBundle\Config\EntityDefinitionConfig;
use Oro\Bundle\ApiBundle\Metadata\EntityMetadata;
use Oro\Bundle\ApiBundle\Metadata\MetadataExtraInterface;
use Oro\Bundle\ApiBundle\Processor\GetMetadata\MetadataContext;
use Oro\Bundle\ApiBundle\Request\RequestType;

class MetadataProvider
{
    /** @var ActionProcessorInterface */
    protected $processor;

    /** @var array */
    protected $cache = [];

    /**
     * @param ActionProcessorInterface $processor
     */
    public function __construct(ActionProcessorInterface $processor)
    {
        $this->processor = $processor;
    }

    /**
     * Gets metadata for the given version of an entity.
     *
     * @param string                      $className   The FQCN of an entity
     * @param string                      $version     The version of a config
     * @param RequestType                 $requestType The request type, for example "rest", "soap", etc.
     * @param MetadataExtraInterface[]    $extras      Requests for additional metadata information
     * @param EntityDefinitionConfig|null $config      The configuration of an entity
     *
     * @return EntityMetadata|null
     */
    public function getMetadata(
        $className,
        $version,
        RequestType $requestType,
        array $extras = [],
        EntityDefinitionConfig $config = null
    ) {
        if (empty($className)) {
            throw new \InvalidArgumentException('$className must not be empty.');
        }

        $configKey = $config
            ? $config->getKey()
            : 'no_config';
        if (!$configKey) {
            return $this->loadMetadata($className, $version, $requestType, $extras, $config);
        }
        
        $cacheKey = $this->buildCacheKey($className, $version, $requestType, $extras, $configKey);
        if (array_key_exists($cacheKey, $this->cache)) {
            return clone $this->cache[$cacheKey];
        }

        $metadata = $this->loadMetadata($className, $version, $requestType, $extras, $config);
        $this->cache[$cacheKey] = $metadata;

        if (null === $metadata) {
            return null;
        }

        return clone $metadata;
{'fraction_non_alphanumeric': 0.10889175257731959, 'fraction_numerical': 0.0006443298969072165, 'mean_word_length': 2.4962462462462462, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6075981', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1206, 'n_words': 304}