<commit_before>Feature: Providing a custom page object factory
  In order to customise the way page objects are created
  As an Experienced Developer
  I need to provide my own implementation of the page object factory

  Scenario: Custom page object factory
    Given a behat configuration:
    """
    default:
      suites:
        default:
          contexts: [SearchContext]
      extensions:
        SensioLabs\Behat\PageObjectExtension:
          factory: acme.page_object.factory
        acme_page_object_extension.php: ~
        Behat\MinkExtension:
          goutte: ~
          base_url: http://localhost:8000
    """
    And an extension file "acme_page_object_extension.php" contains:
    """
    <?php

    use Behat\Mink\Mink;
    use SensioLabs\Behat\PageObjectExtension\PageObject\Element;
    use SensioLabs\Behat\PageObjectExtension\PageObject\InlineElement;
    use SensioLabs\Behat\PageObjectExtension\PageObject\Page;
    use SensioLabs\Behat\PageObjectExtension\PageObject\Factory as BaseFactory;

    class AcmeFactory implements BaseFactory
    {
        /**
         * @var Mink
         */
        private $mink = null;

        /**
         * @var array
         */
        private $pageParameters = array();

        /**
         * @var Mink  $mink
         * @var array $pageParameters
         */
        public function __construct(Mink $mink, array $pageParameters)
        {
            $this->mink = $mink;
            $this->pageParameters = $pageParameters;
        }

        /**
         * @param string $name
         *
         * @return Page
         */
        public function createPage($name)
        {
            return new $name($this->mink->getSession(), $this, $this->pageParameters);
        }

        /**
         * @param string $name
         *
         * @return Element
         */
        public function createElement($name)
        {
            return new $name($this->mink->getSession(), $this);
        }

        /**
         * @param array|string $selector
         *
         * @return InlineElement
         */
        public function createInlineElement($selector)
        {
            return new InlineElement($selector, $this->mink->getSession(), $this);
        }

        /**
         * @param string $class
         *
         * @return PageObject
         */
        public function instantiate($class)
        {
            return new $class($this->mink->getSession(), $this, $this->pageParameters);
        }
    }

    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\Definition;
    use Symfony\Component\DependencyInjection\Reference;

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

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

        /**
         * {@inheritdoc}
         */
        public function configure(ArrayNodeDefinition $builder)
        {
        }

        /**
         * {@inheritdoc}
         */
        public function load(ContainerBuilder $container, array $config)
        {
            $definition = new Definition('AcmeFactory');
            $definition->setArguments([new Reference('mink'), '%mink.parameters%']);
            $container->setDefinition('acme.page_object.factory', $definition);
        }

        /**
         * {@inheritdoc}
         */
        public function process(ContainerBuilder $container)
        {<commit_msg>Fix an example to work with PHP 5.3.<commit_after>Feature: Providing a custom page object factory
  In order to customise the way page objects are created
  As an Experienced Developer
  I need to provide my own implementation of the page object factory

  Scenario: Custom page object factory
    Given a behat configuration:
    """
    default:
      suites:
        default:
          contexts: [SearchContext]
      extensions:
        SensioLabs\Behat\PageObjectExtension:
          factory: acme.page_object.factory
        acme_page_object_extension.php: ~
        Behat\MinkExtension:
          goutte: ~
          base_url: http://localhost:8000
    """
    And an extension file "acme_page_object_extension.php" contains:
    """
    <?php

    use Behat\Mink\Mink;
    use SensioLabs\Behat\PageObjectExtension\PageObject\Element;
    use SensioLabs\Behat\PageObjectExtension\PageObject\InlineElement;
    use SensioLabs\Behat\PageObjectExtension\PageObject\Page;
    use SensioLabs\Behat\PageObjectExtension\PageObject\Factory as BaseFactory;

    class AcmeFactory implements BaseFactory
    {
        /**
         * @var Mink
         */
        private $mink = null;

        /**
         * @var array
         */
        private $pageParameters = array();

        /**
         * @var Mink  $mink
         * @var array $pageParameters
         */
        public function __construct(Mink $mink, array $pageParameters)
        {
            $this->mink = $mink;
            $this->pageParameters = $pageParameters;
        }

        /**
         * @param string $name
         *
         * @return Page
         */
        public function createPage($name)
        {
            return new $name($this->mink->getSession(), $this, $this->pageParameters);
        }

        /**
         * @param string $name
         *
         * @return Element
         */
        public function createElement($name)
        {
            return new $name($this->mink->getSession(), $this);
        }

        /**
         * @param array|string $selector
         *
         * @return InlineElement
         */
        public function createInlineElement($selector)
        {
            return new InlineElement($selector, $this->mink->getSession(), $this);
        }

        /**
         * @param string $class
         *
         * @return PageObject
         */
        public function instantiate($class)
        {
            return new $class($this->mink->getSession(), $this, $this->pageParameters);
        }
    }

    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\Definition;
    use Symfony\Component\DependencyInjection\Reference;

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

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

        /**
         * {@inheritdoc}
         */
        public function configure(ArrayNodeDefinition $builder)
        {
        }

        /**
         * {@inheritdoc}
         */
        public function load(ContainerBuilder $container, array $config)
        {
            $definition = new Definition('AcmeFactory');
            $definition->setArguments(array(new Reference('mink'), '%mink.parameters%'));
            $container->setDefinition('acme.page_object.factory', $definition);
        }

        /**
         * {@inheritdoc}
         */
        public function process(ContainerBuilder $container)
        {
{'fraction_non_alphanumeric': 0.09964322120285422, 'fraction_numerical': 0.0012742099898063201, 'mean_word_length': 1.9091919940696813, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4260405', 'n_tokens_mistral': 2075, 'n_tokens_neox': 2031, 'n_words': 431}