<commit_before><?php namespace Maduser\Minimal\Core;

use Maduser\Minimal\Interfaces\RequestInterface;

/**
 * Class Request
 *
 * @package Maduser\Minimal\Core
 */
class Request implements RequestInterface
{
	/**
     * The current uri string
     *
	 * @var
	 */
	private $uriString;

	/**
     * The current http method
     *
	 * @var
	 */
	private $requestMethod;

	/**
     * Holds all the uri segments until ? or #
     *
	 * @var array
	 */
	private $segments = [];

	/**
     * Setter $uriString
     *
	 * @param $str
	 */
	private function setUriString($str)
	{
		$this->uriString = $str;
	}

	/**
     * Getter $uriString
     *
	 * @return mixed
	 */
	public function getUriString()
	{
		return $this->uriString;
	}

	/**
     * Setter $requestMethod
     *
	 * @param $str
	 */
	public function setRequestMethod($str)
	{
		$this->requestMethod = $str;
	}

	/**
     * Getter $requestMethod
     *
	 * @return mixed
	 */
	public function getRequestMethod()
	{
		return $this->requestMethod;
	}

	/**
     * Setter $segments
     *
	 * @param array $segments
	 */
	public function setSegments(array $segments)
	{
		$this->segments = $segments;
	}

	/**
     * Getter $segments
     *
	 * @return array
	 */
	public function getSegments(): array
	{
		return $this->segments;
	}

	/**
     * Request constructor
     * sets $requestMethod
     * sets $uriString
     * sets $segments
	 */
	public function __construct()
	{
		$this->fetchRequestMethod();
		$this->fetchUriString();
		$this->explodeSegments();
	}

	/**
	 * Determined the http method
	 */
	public function fetchRequestMethod()
	{
		if (isset($_POST['_method'])) {
			if (
				strtoupper($_POST['_method']) == 'PUT' ||
                strtoupper($_POST['_method']) == 'PATCH' ||
                strtoupper($_POST['_method']) == 'DELETE'
			) {
				$this->setRequestMethod(strtoupper($_POST['_method']));
				return;
			}
		}

		$this->setRequestMethod($_SERVER['REQUEST_METHOD']);
	}

	/**
	 * Fetches the REQUEST_URI and sets $uriString<commit_msg>Can now set the request method to CLI<commit_after><?php namespace Maduser\Minimal\Core;

use Maduser\Minimal\Interfaces\RequestInterface;

/**
 * Class Request
 *
 * @package Maduser\Minimal\Core
 */
class Request implements RequestInterface
{
	/**
     * The current uri string
     *
	 * @var
	 */
	private $uriString;

	/**
     * The current http method
     *
	 * @var
	 */
	private $requestMethod;

	/**
     * Holds all the uri segments until ? or #
     *
	 * @var array
	 */
	private $segments = [];

	/**
     * Setter $uriString
     *
	 * @param $str
	 */
	private function setUriString($str)
	{
		$this->uriString = $str;
	}

	/**
     * Getter $uriString
     *
	 * @return mixed
	 */
	public function getUriString()
	{
		return $this->uriString;
	}

	/**
     * Setter $requestMethod
     *
	 * @param $str
	 */
	public function setRequestMethod($str)
	{
		$this->requestMethod = $str;
	}

	/**
     * Getter $requestMethod
     *
	 * @return mixed
	 */
	public function getRequestMethod()
	{
		return $this->requestMethod;
	}

	/**
     * Setter $segments
     *
	 * @param array $segments
	 */
	public function setSegments(array $segments)
	{
		$this->segments = $segments;
	}

	/**
     * Getter $segments
     *
	 * @return array
	 */
	public function getSegments(): array
	{
		return $this->segments;
	}

	/**
     * Request constructor
     * sets $requestMethod
     * sets $uriString
     * sets $segments
	 */
	public function __construct()
	{
		$this->fetchRequestMethod();
		$this->fetchUriString();
		$this->explodeSegments();
	}

	/**
	 * Determined the http method
	 */
	public function fetchRequestMethod()
	{
        if (php_sapi_name() == 'cli' or defined('STDIN')) {
            $this->setRequestMethod('CLI');
            return;
        }

        if (isset($_POST['_method'])) {
			if (
				strtoupper($_POST['_method']) == 'PUT' ||
                strtoupper($_POST['_method']) == 'PATCH' ||
                strtoupper($_POST['_method']) == 'DELETE'
			) {
				$this->setRequestMethod(strtoupper($_POST['_method']));
				return;
			}
		}

		$this->setRequestMethod($_SERVER['REQUEST_METHOD']);
	}

	/**
	 * Fetches the REQUEST_URI and sets $uriString
{'fraction_non_alphanumeric': 0.1522203752077891, 'fraction_numerical': 0.0, 'mean_word_length': 2.551433389544688, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, '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': '2240643', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1384, 'n_words': 281}