<commit_before><?php

namespace AssetManager\Service;

use Assetic\Cache\CacheInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
 * Factory class for AssetManagerService
 *
 * @category   AssetManager
 * @package    AssetManager
 */
class AssetCacheProviderServiceFactory implements FactoryInterface
{
    /**
     * {@inheritDoc}
     *
     * @return array
     */
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config  = $serviceLocator->get('Config');
        $cachingDefinitions = array();

        $return = array();

        if (!empty($config['asset_manager']['caching'])) {
            $cachingDefinitions = $config['asset_manager']['caching'];
        }

        foreach ($cachingDefinitions as $path => $cacheProviderDefinition) {

            if (empty($cacheProviderDefinition['cache'])) {
                continue;

            } elseif (is_callable($cacheProviderDefinition['cache'])) {
                $provider = $cacheProviderDefinition['cache']($path);

            } elseif ($serviceLocator->has($cacheProviderDefinition['cache'])) {
                $provider = $serviceLocator->get($cacheProviderDefinition['cache']);

            } else {
                $dir = '';
                $class = $cacheProviderDefinition['cache'];

                if (!empty($options['dir'])) {
                    $dir = $options['dir'];
                }

                $class = $this->classMapper($class);
                $provider = new $class($dir, $path);
            }

            if (!$provider instanceof CacheInterface) {
                continue;
            }

            $return[$path] = $provider;
        }

        return $return;
    }

    /**
     * Class mapper to provide BC compatibility
     * @param $class
     *
     * @return string
     */
    private function classMapper($class)
    {
        $classToCheck = $class;
        $classToCheck .= (substr($class, -5) === 'Cache') ? '' : 'Cache';

        switch ($classToCheck) {
            case 'ApcCache':
                $class = 'Assetic\Cache\ApcCache';
            break;
            case 'FilesystemCache':
                $class = 'Assetic\Cache\FilesystemCache';
            break;
            case 'FilePathCache':
                $class = 'AssetManager\Cache\FilePathCache';
            break;
        }

        return $class;
    }
}<commit_msg>Fix for coding style errors.<commit_after><?php

namespace AssetManager\Service;

use Assetic\Cache\CacheInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
 * Factory class for AssetManagerService
 *
 * @category   AssetManager
 * @package    AssetManager
 */
class AssetCacheProviderServiceFactory implements FactoryInterface
{
    /**
     * {@inheritDoc}
     *
     * @return array
     */
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config  = $serviceLocator->get('Config');
        $cachingDefinitions = array();

        $return = array();

        if (!empty($config['asset_manager']['caching'])) {
            $cachingDefinitions = $config['asset_manager']['caching'];
        }

        foreach ($cachingDefinitions as $path => $cacheProviderDefinition) {

            if (empty($cacheProviderDefinition['cache'])) {
                continue;

            } elseif (is_callable($cacheProviderDefinition['cache'])) {
                $provider = $cacheProviderDefinition['cache']($path);

            } elseif ($serviceLocator->has($cacheProviderDefinition['cache'])) {
                $provider = $serviceLocator->get($cacheProviderDefinition['cache']);

            } else {
                $dir = '';
                $class = $cacheProviderDefinition['cache'];

                if (!empty($options['dir'])) {
                    $dir = $options['dir'];
                }

                $class = $this->classMapper($class);
                $provider = new $class($dir, $path);
            }

            if (!$provider instanceof CacheInterface) {
                continue;
            }

            $return[$path] = $provider;
        }

        return $return;
    }

    /**
     * Class mapper to provide BC compatibility
     * @param $class
     *
     * @return string
     */
    private function classMapper($class)
    {
        $classToCheck = $class;
        $classToCheck .= (substr($class, -5) === 'Cache') ? '' : 'Cache';

        switch ($classToCheck) {
            case 'ApcCache':
                $class = 'Assetic\Cache\ApcCache';
                break;
            case 'FilesystemCache':
                $class = 'Assetic\Cache\FilesystemCache';
                break;
            case 'FilePathCache':
                $class = 'AssetManager\Cache\FilePathCache';
                break;
        }

        return $class;
    }
}
{'fraction_non_alphanumeric': 0.12910462981847848, 'fraction_numerical': 0.0004079135223332653, 'mean_word_length': 1.950661853188929, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '6742307', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1211, 'n_words': 236}