<commit_before><?php

namespace SensioLabs\Behat\PageObjectExtension\ServiceContainer;

use Behat\Testwork\ServiceContainer\Extension as TestworkExtension;
use Behat\Testwork\ServiceContainer\ExtensionManager;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

class PageObjectExtension implements TestworkExtension
{
    /**
     * {@inheritdoc}
     */
    public function getConfigKey()
    {
        return 'page_object';
    }

    /**
     * {@inheritdoc}
     */
    public function initialize(ExtensionManager $extensionManager)
    {
    }

    /**
     * {@inheritdoc}
     */
    public function configure(ArrayNodeDefinition $builder)
    {
        $namespaces = $builder->children()->arrayNode('namespaces')->children();

        foreach (array('page', 'element') as $namespaceType) {
            $namespace = $namespaces->arrayNode($namespaceType);
            $namespace->beforeNormalization()->ifString()->then(function ($v) { return array($v); } );
            $namespace->prototype('scalar');
        }
    }

    /**
     * {@inheritdoc}
     */
    public function load(ContainerBuilder $container, array $config)
    {
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/config'));
        $loader->load('services.xml');

        $this->updateNamespaceParameters($container, $config);
    }

    /**
     * {@inheritdoc}
     */
    public function process(ContainerBuilder $container)
    {
    }

    /**
     * @param ContainerBuilder $container
     * @param array            $config
     */
    private function updateNamespaceParameters(ContainerBuilder $container, array $config)
    {
        $namespaces = $config['namespaces'];

        if (!empty($namespaces['page'])) {
            $container->setParameter('sensio_labs.page_object_extension.namespaces.page', $namespaces['page']);
            $namespaces['element'] = $namespaces['element'] ?: array_map(function ($v) { return $v.'\Element'; }, $namespaces['page']);
        }

        if (!empty($namespaces['element'])) {
            $container->setParameter('sensio_labs.page_object_extension.namespaces.element', $namespaces['element']);
        }
    }
}
<commit_msg>Bring back the check to make phpspec happy again.<commit_after><?php

namespace SensioLabs\Behat\PageObjectExtension\ServiceContainer;

use Behat\Testwork\ServiceContainer\Extension as TestworkExtension;
use Behat\Testwork\ServiceContainer\ExtensionManager;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

class PageObjectExtension implements TestworkExtension
{
    /**
     * {@inheritdoc}
     */
    public function getConfigKey()
    {
        return 'page_object';
    }

    /**
     * {@inheritdoc}
     */
    public function initialize(ExtensionManager $extensionManager)
    {
    }

    /**
     * {@inheritdoc}
     */
    public function configure(ArrayNodeDefinition $builder)
    {
        $namespaces = $builder->children()->arrayNode('namespaces')->children();

        foreach (array('page', 'element') as $namespaceType) {
            $namespace = $namespaces->arrayNode($namespaceType);
            $namespace->beforeNormalization()->ifString()->then(function ($v) { return array($v); } );
            $namespace->prototype('scalar');
        }
    }

    /**
     * {@inheritdoc}
     */
    public function load(ContainerBuilder $container, array $config)
    {
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/config'));
        $loader->load('services.xml');

        if (isset($config['namespaces'])) {
            $this->updateNamespaceParameters($container, $config['namespaces']);
        }
    }

    /**
     * {@inheritdoc}
     */
    public function process(ContainerBuilder $container)
    {
    }

    /**
     * @param ContainerBuilder $container
     * @param array            $namespaces
     */
    private function updateNamespaceParameters(ContainerBuilder $container, array $namespaces)
    {
        if (!empty($namespaces['page'])) {
            $container->setParameter('sensio_labs.page_object_extension.namespaces.page', $namespaces['page']);
            $namespaces['element'] = $namespaces['element'] ?: array_map(function ($v) { return $v.'\Element'; }, $namespaces['page']);
        }

        if (!empty($namespaces['element'])) {
            $container->setParameter('sensio_labs.page_object_extension.namespaces.element', $namespaces['element']);
        }
    }
}

{'fraction_non_alphanumeric': 0.13928273561301086, 'fraction_numerical': 0.0, 'mean_word_length': 3.1931818181818183, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5220728', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1270, 'n_words': 208}