<commit_before><?php namespace Waynestate\Promotions;

use Waynestate\Promotions\ParserInterface;
use Waynestate\Promotions\ParsePromosException;

/**
 * Class ParsePromos
 * @package Waynestate\Promotions
 */
class ParsePromos implements ParserInterface
{
    /**
     * Parse the promotions array
     *
     * @param array $promos
     * @param array $group_reference
     * @param array $config
     * @return array
     */
    public function parse(array &$promos, array $group_reference, array $config = array())
    {
        $promotions = array();

        // Re-organize by group id
        if (is_array($promos['promotions'])) {
            // Loop through each promo item
            foreach ($promos['promotions'] as $item) {
                // Organize them by their reference
                $promotions[$group_reference[$item['promo_group_id']]][$item['promo_item_id']] = $item;
            }
        }

        // If there are special config cases
        if (is_array($config) && count($config) > 0) {
            // Key should be the group ID
            foreach ($config as $group_name => $option) {
                // If there is a group with this ID
                if (array_key_exists($group_name, $promotions)) {
                    // Perform the action
                    $promotions[$group_name] = $this->performConfig($promotions[$group_name], $option);
                }
            }
        }

        return $promotions;
    }

    /**
     * Parse the promotions array
     *
     * @param array $promos
     * @param array $group_reference
     * @return array
     */
    public function groups(array $promos, array $group_reference = array()) {
        $groups = array();

        // Make sure we have promotional items
        if(is_array($promos)) {
            foreach($promos as $items) {
                // Get the first item in that group
                $first_item = current($items);<commit_msg>PSR-2 fixes<commit_after><?php namespace Waynestate\Promotions;

use Waynestate\Promotions\ParserInterface;
use Waynestate\Promotions\ParsePromosException;

/**
 * Class ParsePromos
 * @package Waynestate\Promotions
 */
class ParsePromos implements ParserInterface
{
    /**
     * Parse the promotions array
     *
     * @param array $promos
     * @param array $group_reference
     * @param array $config
     * @return array
     */
    public function parse(array &$promos, array $group_reference, array $config = array())
    {
        $promotions = array();

        // Re-organize by group id
        if (is_array($promos['promotions'])) {
            // Loop through each promo item
            foreach ($promos['promotions'] as $item) {
                // Organize them by their reference
                $promotions[$group_reference[$item['promo_group_id']]][$item['promo_item_id']] = $item;
            }
        }

        // If there are special config cases
        if (is_array($config) && count($config) > 0) {
            // Key should be the group ID
            foreach ($config as $group_name => $option) {
                // If there is a group with this ID
                if (array_key_exists($group_name, $promotions)) {
                    // Perform the action
                    $promotions[$group_name] = $this->performConfig($promotions[$group_name], $option);
                }
            }
        }

        return $promotions;
    }

    /**
     * Parse the promotions array
     *
     * @param array $promos
     * @param array $group_reference
     * @return array
     */
    public function groups(array $promos, array $group_reference = array())
    {
        $groups = array();

        // Make sure we have promotional items
        if (is_array($promos)) {
            foreach ($promos as $items) {
                // Get the first item in that group
                $first_item = current($items);
{'fraction_non_alphanumeric': 0.11148300720906282, 'fraction_numerical': 0.000772399588053553, 'mean_word_length': 1.963386727688787, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3056429', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1038, 'n_words': 288}