header = new ConsoleHeader(); $this->header->l11n = $l11n ?? new Localization(); $this->uri = $uri ?? new Argument(); $this->init(); } /** * Init request. * * This is used in order to either initialize the current http request or a batch of GET requests * * @return void * * @since 1.0.0 */ private function init() : void { $this->header->l11n->setLanguage('en'); } /** * Create request hashs of current request * * The hashes are based on the request path and can be used as unique id. * * @param int $start Start hash from n-th path element * * @return void * * @since 1.0.0 */ public function createRequestHashs(int $start = 0) : void { $this->hash = [\sha1('')]; $pathArray = $this->uri->getPathElements(); $pathLength = \count($pathArray); for ($i = $start; $i < $pathLength; ++$i) { if ($pathArray[$i] === '') { continue; } $paths = []; for ($j = $start; $j <= $i; ++$j) { $paths[] = $pathArray[$j]; } $this->hash[] = \sha1(\implode('', $paths)); } } /** * Set request method. * * @param string $method Request method * * @return void * * @since 1.0.0 */ public function setMethod(string $method) : void { $this->method = $method; } /** * Get request method. * * @return string * * @since 1.0.0 */ public function getMethod() : string { return $this->method; } /** * Determine request OS. * * @return string * * @since 1.0.0 */ public function getOS() : string { if (!isset($this->os)) { $this->os = \strtolower(\PHP_OS); } return $this->os; } /** * Set OS type * * @param string $os OS type * * @return void * * @since 1.0.0 */ public function setOS(string $os) : void { $this->os = $os; } /** * {@inheritdoc} */ public function getOrigin() : string { return '127.0.0.1'; } /** * {@inheritdoc} */ public function getBody() : string { return ''; } }