<commit_before><?php
namespace Granam\Tools;

class ValueDescriberTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var ValueDescriber
     */
    private $describer;

    protected function setUp()
    {
        $this->describer = new ValueDescriber();
    }

    /**
     * @test
     */
    public function I_can_describe_scalar_and_null()
    {
        $this->assertSame('123', $this->describer->describe(123));
        $this->assertSame('123.456', $this->describer->describe(123.456));
        $this->assertSame("'foo'", $this->describer->describe('foo'));
        $this->assertSame('NULL', $this->describer->describe(null));
        $this->assertSame('true', $this->describer->describe(true));
    }

    /**
     * @test
     */
    public function I_can_describe_object()
    {
        $this->assertSame('instance of stdClass', $this->describer->describe(new \stdClass()));
        $value = 'foo';
        $this->assertSame(
            'instance of ' . __NAMESPACE__ . '\ToStringObject ' . "($value)",
            $this->describer->describe(new ToStringObject($value))
        );
    }

    /**
     * @test
     */
    public function I_can_describe_array_and_resource()
    {
        $this->assertSame('array', $this->describer->describe([]));
        $this->assertSame('resource', $this->describer->describe(tmpfile()));
    }
}

/** inner */
class ToStringObject
{

    private $value;

    public function __construct($value)
    {
        $this->value = $value;
    }

    public function __toString()
    {
        return (string)$this->value;
    }
}<commit_msg>Fixed compatibility with PHP 5.3<commit_after><?php
namespace Granam\Tools;

class ValueDescriberTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var ValueDescriber
     */
    private $describer;

    protected function setUp()
    {
        $this->describer = new ValueDescriber();
    }

    /**
     * @test
     */
    public function I_can_describe_scalar_and_null()
    {
        $this->assertSame('123', $this->describer->describe(123));
        $this->assertSame('123.456', $this->describer->describe(123.456));
        $this->assertSame("'foo'", $this->describer->describe('foo'));
        $this->assertSame('NULL', $this->describer->describe(null));
        $this->assertSame('true', $this->describer->describe(true));
    }

    /**
     * @test
     */
    public function I_can_describe_object()
    {
        $this->assertSame('instance of stdClass', $this->describer->describe(new \stdClass()));
        $value = 'foo';
        $this->assertSame(
            'instance of ' . __NAMESPACE__ . '\ToStringObject ' . "($value)",
            $this->describer->describe(new ToStringObject($value))
        );
    }

    /**
     * @test
     */
    public function I_can_describe_array_and_resource()
    {
        $this->assertSame('array', $this->describer->describe(array()));
        $this->assertSame('resource', $this->describer->describe(tmpfile()));
    }
}

/** inner */
class ToStringObject
{

    private $value;

    public function __construct($value)
    {
        $this->value = $value;
    }

    public function __toString()
    {
        return (string)$this->value;
    }
}
{'fraction_non_alphanumeric': 0.1684375, 'fraction_numerical': 0.011875, 'mean_word_length': 2.60472972972973, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, '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': '2637194', 'n_tokens_mistral': 1045, 'n_tokens_neox': 958, 'n_words': 150}