<commit_before><?php
/*
 * Copyright (c) Ouzo contributors, https://github.com/letsdrink/ouzo
 * This file is made available under the MIT License (view the LICENSE file for more information).
 */

use Ouzo\Utilities\Booleans;
use Ouzo\Utilities\Objects;
use PHPUnit\Framework\TestCase;

class BooleansTest extends TestCase
{
    /**
     * @test
     * @dataProvider toBoolean
     */
    public function shouldConvertToBoolean(string $string, string $expected)
    {
        //when
        $toBoolean = Booleans::toBoolean($string);

        //then
        $this->assertEquals($expected, $toBoolean, 'To convert: ' . Objects::toString($string) . ' Expected: ' . Objects::toString($expected));
    }

    public function toBoolean(): array
    {
        return [
            [true, true],
            [null, false],
            ['true', true],
            ['TRUE', true],
            ['tRUe', true],
            ['on', true],
            ['yes', true],
            ['false', false],
            ['x gti', false],
            ['0', false],
            ['1', true],
            ['2', true],
            [0, false],
            [1, true],
            [2, true]
        ];
    }
}
<commit_msg>[php8] Refactoring code to use PHP 8 features.<commit_after><?php
/*
 * Copyright (c) Ouzo contributors, https://github.com/letsdrink/ouzo
 * This file is made available under the MIT License (view the LICENSE file for more information).
 */

use Ouzo\Utilities\Booleans;
use Ouzo\Utilities\Objects;
use PHPUnit\Framework\TestCase;

class BooleansTest extends TestCase
{
    /**
     * @test
     * @dataProvider toBoolean
     */
    public function shouldConvertToBoolean(mixed $string, bool $expected)
    {
        //when
        $toBoolean = Booleans::toBoolean($string);

        //then
        $this->assertEquals($expected, $toBoolean, 'To convert: ' . Objects::toString($string) . ' Expected: ' . Objects::toString($expected));
    }

    public function toBoolean(): array
    {
        return [
            [true, true],
            [null, false],
            ['true', true],
            ['TRUE', true],
            ['tRUe', true],
            ['on', true],
            ['yes', true],
            ['false', false],
            ['x gti', false],
            ['0', false],
            ['1', true],
            ['2', true],
            [0, false],
            [1, true],
            [2, true]
        ];
    }
}

{'fraction_non_alphanumeric': 0.14896265560165975, 'fraction_numerical': 0.005809128630705394, 'mean_word_length': 1.8874251497005987, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '364567', 'n_tokens_mistral': 697, 'n_tokens_neox': 689, 'n_words': 183}