<commit_before><?php

namespace SlotMachine;

use Symfony\Component\HttpFoundation\Request;

/**
 *  The base for a new dynamic landing page.
 *  Each dynamic placeholder is called a slot
 *  where a slot will hold many cards for one
 *  to be displayed depending on a set of
 *  given parameters.
 *
 *  @package slotmachine
 *  @author <NAME> <<EMAIL>>
 */
class Page extends \Pimple
{
    /**
     *  The Symfony HttpFoundation Request object.
     */
    protected $request;

    /**
     *  Raw configuration data.
     */
    protected $config = array();

    /**
     *  The delimiter token for nested data
     */
    protected $delimiter = array('{', '}');

    /**
     *  Loads the config data and creates new Slot instances.
     *  A custom Request can be injected, otherwise defaults 
     *  to creating one from PHP globals.
     *
     *  @param array $config
     *  @param Request $request
     */
    public function __construct(array $config, Request $request = null)
    {
        parent::__construct();

        $page = $this;

        $this->request = (is_null($request)) ? Request::createFromGlobals() : $request;
        $this->config  = $config;

        if (isset($this->config['options']['delimiter'])) {
            $numberOfTokens = count($this->config['options']['delimiter']);
            if (2 === $numberOfTokens) {
                $this->delimiter = $this->config['options']['delimiter'];
            } else {
                throw new LengthException(sprintf(
                    'The page must be configured to receive an array of exactly 2 tokens, one opening and one closing. %d given.',
                    $numberOfTokens
                ));
            }
        }

        $this['slot_class'] = 'SlotMachine\\Slot';

        // create new instances for each slot configured
        foreach ($config['slots'] as $slotName => $slotData) {
            $this[$slotName] = $this->share(function ($page) use ($slotName, $slotData) {
                return new $page['slot_class']($slotName, $slotData);
            });
        }

        // inject nested slots<commit_msg>Fix namespacing issue for throwing LengthException<commit_after><?php

namespace SlotMachine;

use Symfony\Component\HttpFoundation\Request;

/**
 *  The base for a new dynamic landing page.
 *  Each dynamic placeholder is called a slot
 *  where a slot will hold many cards for one
 *  to be displayed depending on a set of
 *  given parameters.
 *
 *  @package slotmachine
 *  @author <NAME> <<EMAIL>>
 */
class Page extends \Pimple
{
    /**
     *  The Symfony HttpFoundation Request object.
     */
    protected $request;

    /**
     *  Raw configuration data.
     */
    protected $config = array();

    /**
     *  The delimiter token for nested data
     */
    protected $delimiter = array('{', '}');

    /**
     *  Loads the config data and creates new Slot instances.
     *  A custom Request can be injected, otherwise defaults 
     *  to creating one from PHP globals.
     *
     *  @param array $config
     *  @param Request $request
     */
    public function __construct(array $config, Request $request = null)
    {
        parent::__construct();

        $page = $this;

        $this->request = (is_null($request)) ? Request::createFromGlobals() : $request;
        $this->config  = $config;

        if (isset($this->config['options']['delimiter'])) {
            $numberOfTokens = count($this->config['options']['delimiter']);
            if (2 === $numberOfTokens) {
                $this->delimiter = $this->config['options']['delimiter'];
            } else {
                throw new \LengthException(sprintf(
                    'The page must be configured to receive an array of exactly 2 tokens, one opening and one closing. %d given.',
                    $numberOfTokens
                ));
            }
        }

        $this['slot_class'] = 'SlotMachine\\Slot';

        // create new instances for each slot configured
        foreach ($config['slots'] as $slotName => $slotData) {
            $this[$slotName] = $this->share(function ($page) use ($slotName, $slotData) {
                return new $page['slot_class']($slotName, $slotData);
            });
        }

        // inject nested slots
{'fraction_non_alphanumeric': 0.12376702677313292, 'fraction_numerical': 0.0009394081728511038, 'mean_word_length': 2.161841128433556, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, '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': '2193852', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1135, 'n_words': 356}