<commit_before><?php

namespace Machete\Validation;

use Machete\Validation\Pointer\InvalidPointerException;
use Machete\Validation\Pointer\Parser;

/**
 * A simple JSON Pointer implementation that can traverse
 * an object resulting from a json_decode() call.
 */
class Pointer
{
    /**
     * Pointer constructor.
     * @param object $json
     */
    public function __construct($json)
    {
        $this->json = $json;
    }

    /**
     * @param string $pointer
     * @return mixed
     * @throws InvalidPointerException
     */
    public function get($pointer)
    {
        if ($pointer === '') {
            return $this->json;
        }

        $pointer = (new Parser($pointer))->parse();

        return $this->traverse($this->json, $pointer);
    }

    /**
     * @param string $pointer
     * @return bool
     */
    public function has($pointer)<commit_msg>declare the json property<commit_after><?php

namespace Machete\Validation;

use Machete\Validation\Pointer\InvalidPointerException;
use Machete\Validation\Pointer\Parser;

/**
 * A simple JSON Pointer implementation that can traverse
 * an object resulting from a json_decode() call.
 */
class Pointer
{
    /**
     * @var object
     */
    private $json;

    /**
     * Pointer constructor.
     * @param object $json
     */
    public function __construct($json)
    {
        $this->json = $json;
    }

    /**
     * @param string $pointer
     * @return mixed
     * @throws InvalidPointerException
     */
    public function get($pointer)
    {
        if ($pointer === '') {
            return $this->json;
        }

        $pointer = (new Parser($pointer))->parse();

        return $this->traverse($this->json, $pointer);
    }

    /**
     * @param string $pointer
     * @return bool
     */
    public function has($pointer)
{'fraction_non_alphanumeric': 0.12986301369863013, 'fraction_numerical': 0.0, 'mean_word_length': 2.272401433691756, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '1597202', 'n_tokens_mistral': 520, 'n_tokens_neox': 508, 'n_words': 130}