<commit_before><?php

namespace Marmelab\Dobble;

abstract class DeckValidator
{
    public function validate($deck)
    {
        self::validateDeckIsNotEmpty($deck);
        self::validateDeckHasNoIdenticalCards($deck);
        self::validateDeckCardsHaveSameSymbolNumber($deck);
        self::validateDeckCardsHaveUniqueSymbolsCouple($deck);

        return true;
    }

    public function validateDeckIsNotEmpty($deck)
    {
        if (!count($deck)) {
            throw new DobbleException('The deck is empty');
        }
    }

    public function validateDeckHasNoIdenticalCards($deck)
    {
        if (count(array_unique($deck->getCards())) < count($deck)) {
            throw new DobbleException('The deck has two or more identical cards');
        }
    }

    public function validateDeckCardsHaveSameSymbolNumber($deck)
    {
        $countAllCards = array_map('count', $deck->getCards());
        if (count(array_unique($countAllCards)) > 1) {
            throw new DobbleException('Cards have different number of symbol');
        }
    }

    public function validateDeckCardsHaveUniqueSymbolsCouple($deck)
    {
        $symbols = array();

        // Fetch all symbols
        foreach ($deck->getCards() as $card) {
            foreach ($card->getSymbols() as $symbol) {
                array_push($symbols, $symbol);
            }
        }

        // Count all symbol in array
        $symbolMap = array_count_values($symbols);

        // If one of them is counted more than twice, raise exception
        if (count(array_unique($symbolMap)) != 1 || end($symbolMap) > 2) {
            throw new DobbleException('More than two cards have same symbol');
        }
    }
}<commit_msg>Miss static function<commit_after><?php

namespace Marmelab\Dobble;

abstract class DeckValidator
{
    public static function validate($deck)
    {
        self::validateDeckIsNotEmpty($deck);
        self::validateDeckHasNoIdenticalCards($deck);
        self::validateDeckCardsHaveSameSymbolNumber($deck);
        self::validateDeckCardsHaveUniqueSymbolsCouple($deck);

        return true;
    }

    public static function validateDeckIsNotEmpty($deck)
    {
        if (!count($deck)) {
            throw new DobbleException('The deck is empty');
        }
    }

    public static function validateDeckHasNoIdenticalCards($deck)
    {
        if (count(array_unique($deck->getCards())) < count($deck)) {
            throw new DobbleException('The deck has two or more identical cards');
        }
    }

    public static function validateDeckCardsHaveSameSymbolNumber($deck)
    {
        $countAllCards = array_map('count', $deck->getCards());
        if (count(array_unique($countAllCards)) > 1) {
            throw new DobbleException('Cards have different number of symbol');
        }
    }

    public static function validateDeckCardsHaveUniqueSymbolsCouple($deck)
    {
        $symbols = array();

        // Fetch all symbols
        foreach ($deck->getCards() as $card) {
            foreach ($card->getSymbols() as $symbol) {
                array_push($symbols, $symbol);
            }
        }

        // Count all symbol in array
        $symbolMap = array_count_values($symbols);

        // If one of them is counted more than twice, raise exception
        if (count(array_unique($symbolMap)) != 1 || end($symbolMap) > 2) {
            throw new DobbleException('More than two cards have same symbol');
        }
    }
}
{'fraction_non_alphanumeric': 0.10892236384704519, 'fraction_numerical': 0.0017381228273464658, 'mean_word_length': 2.5671487603305785, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '3075073', 'n_tokens_mistral': 972, 'n_tokens_neox': 956, 'n_words': 225}