<commit_before><?php

namespace Plates\Extension;

class URI
{
    public $methods = array('uri');
    public $engine;
    public $template;
    public $uri;

    public function __construct($uri)
    {
        $this->uri = $uri;
        $this->parts = explode('/', $this->uri);
    }

    public function uri($var1 = null, $var2 = null, $var3 = null, $var4 = null)
    {
        if (is_null($var1)) {
            return $this->uri;
        }

        if (is_numeric($var1) and is_null($var2) and is_null($var3) and is_null($var4)) {
            return $this->parts[$var1];
        }

        if (is_numeric($var1) and is_string($var2) and is_null($var3) and is_null($var4)) {
            return $this->parts[$var1] === $var2;
        }

        if (is_numeric($var1) and is_string($var2) and is_string($var3) and is_null($var4)) {
            if ($this->parts[$var1] === $var2) {
                return $var3;
            } else {
                return false;
            }
        }

        if (is_numeric($var1) and is_string($var2) and is_string($var3) and is_string($var4)) {
            if ($this->parts[$var1] === $var2) {
                return $var3;
            } else {
                return $var3;
            }
        }

        if (is_string($var1) and is_null($var2) and is_null($var3) and is_null($var4)) {
            return preg_match('#^' . $this->uri . '$#', $var1) === 1;
        }

        if (is_string($var1) and is_string($var2) and is_null($var3) and is_null($var4)) {
            if (preg_match('#^' . $this->uri . '$#', $var1) === 1) {
                return $var2;
            } else {
                return false;
            }
        }

        if (is_string($var1) and is_string($var2) and is_string($var3) and is_null($var4)) {
            if (preg_match('#^' . $this->uri . '$#', $var1) === 1) {
                return $var2;
            } else {
                return $var3;
            }
        }

        throw new \LogicException('Invalid use of the uri() method.');
    }
}
<commit_msg>Fix bug in URI extension when doing regex comparisons.<commit_after><?php

namespace Plates\Extension;

class URI
{
    public $methods = array('uri');
    public $engine;
    public $template;
    public $uri;

    public function __construct($uri)
    {
        $this->uri = $uri;
        $this->parts = explode('/', $this->uri);
    }

    public function uri($var1 = null, $var2 = null, $var3 = null, $var4 = null)
    {
        if (is_null($var1)) {
            return $this->uri;
        }

        if (is_numeric($var1) and is_null($var2) and is_null($var3) and is_null($var4)) {
            return $this->parts[$var1];
        }

        if (is_numeric($var1) and is_string($var2) and is_null($var3) and is_null($var4)) {
            return $this->parts[$var1] === $var2;
        }

        if (is_numeric($var1) and is_string($var2) and is_string($var3) and is_null($var4)) {
            if ($this->parts[$var1] === $var2) {
                return $var3;
            } else {
                return false;
            }
        }

        if (is_numeric($var1) and is_string($var2) and is_string($var3) and is_string($var4)) {
            if ($this->parts[$var1] === $var2) {
                return $var3;
            } else {
                return $var3;
            }
        }

        if (is_string($var1) and is_null($var2) and is_null($var3) and is_null($var4)) {
            return preg_match('#^' . $var1 . '$#', $this->uri) === 1;
        }

        if (is_string($var1) and is_string($var2) and is_null($var3) and is_null($var4)) {
            if (preg_match('#^' . $var1 . '$#', $this->uri) === 1) {
                return $var2;
            } else {
                return false;
            }
        }

        if (is_string($var1) and is_string($var2) and is_string($var3) and is_null($var4)) {
            if (preg_match('#^' . $var1 . '$#', $this->uri) === 1) {
                return $var2;
            } else {
                return $var3;
            }
        }

        throw new \LogicException('Invalid use of the uri() method.');
    }
}

{'fraction_non_alphanumeric': 0.16143170197224252, 'fraction_numerical': 0.02532261991721451, 'mean_word_length': 1.716931216931217, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '6860258', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1348, 'n_words': 300}