<commit_before><?php 

/**
* This class is part of the core of Niuware WebFramework 
* and is not particularly intended to be modified.
* For information about the license please visit the 
* GIT repository at:
* https://github.com/niuware/web-framework
*/
namespace Niuware\WebFramework;
    
/**
* HTTP request class
*/
final class HttpRequest {
    
    private $headers = [];
    
    private $attributes = [];
    
    private $files = [];
    
    /**
     * Gets a request property
     * @param string $name
     * @return mixed
     */
    public function __get($name) {

        if (isset($this->attributes[$name])) {
            
            return $this->attributes[$name];
        }
        
        return null;
    }

    /**
     * Sets a request property
     * @param string $name
     * @param string $value
     */
    public function __set($name, $value) {

        $this->attributes[$name] = $value;
    }

    function __construct(array $params = null, $files = null, $requestUri = null) { 
        
        if ($params !== null) {
            
            $this->attributes = $params;
        }
        
        if ($files !== null) {
            
            $this->files = $files;
        }
        
        $this->setHeaders();
        
        $uri = $requestUri;
        
        if (is_array($requestUri)) {
            
            if (isset($requestUri['path'])) {
                
                $uri = $requestUri['path'];
            }
        }
        
        $this->headers['Request-Path'] = $uri;
        $this->headers['Request-Uri'] = \App\Config\BASE_URL . $uri;
    }
    
    /**
     * Sets all HTTP headers
     */
    private function setHeaders() {
        
        if (function_exists('getallheaders')) {
            
            $this->headers = getallheaders();
        }
        else {
        
            $headers = ""; 
            
            foreach (array_keys($_SERVER) as $header) {
                
                if (substr($header, 0, 5) == 'HTTP_') { 
                    
                    $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($header, 5)))))] = filter_input(INPUT_SERVER, $header); 
                } 
            } 

            $this->headers = $headers; 
        }
    }
    
    /**
     * Gets all HTTP headers
     * @return array
     */
    public function headers() {
        
        return $this->headers;
    }
    
    /**
     * Verifies if a request parameter is set
     * @param type $parameter
     * @param boolean $emptyIsValid
     * @return boolean
     */
    private function hasParameter($parameter, $emptyIsValid) {<commit_msg>Now is possible to retrieve a single HttpRequest header value<commit_after><?php 

/**
* This class is part of the core of Niuware WebFramework 
* and is not particularly intended to be modified.
* For information about the license please visit the 
* GIT repository at:
* https://github.com/niuware/web-framework
*/
namespace Niuware\WebFramework;
    
/**
* HTTP request class
*/
final class HttpRequest {
    
    private $headers = [];
    
    private $attributes = [];
    
    private $files = [];
    
    /**
     * Gets a request property
     * @param string $name
     * @return mixed
     */
    public function __get($name) {

        if (isset($this->attributes[$name])) {
            
            return $this->attributes[$name];
        }
        
        return null;
    }

    /**
     * Sets a request property
     * @param string $name
     * @param string $value
     */
    public function __set($name, $value) {

        $this->attributes[$name] = $value;
    }

    function __construct(array $params = null, $files = null, $requestUri = null) { 
        
        if ($params !== null) {
            
            $this->attributes = $params;
        }
        
        if ($files !== null) {
            
            $this->files = $files;
        }
        
        $this->setHeaders();
        
        $uri = $requestUri;
        
        if (is_array($requestUri)) {
            
            if (isset($requestUri['path'])) {
                
                $uri = $requestUri['path'];
            }
        }
        
        $this->headers['Request-Path'] = $uri;
        $this->headers['Request-Uri'] = \App\Config\BASE_URL . $uri;
    }
    
    /**
     * Sets all HTTP headers
     */
    private function setHeaders() {
        
        if (function_exists('getallheaders')) {
            
            $this->headers = getallheaders();
        }
        else {
        
            $headers = ""; 
            
            foreach (array_keys($_SERVER) as $header) {
                
                if (substr($header, 0, 5) == 'HTTP_') { 
                    
                    $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($header, 5)))))] = filter_input(INPUT_SERVER, $header); 
                } 
            } 

            $this->headers = $headers; 
        }
    }
    
    /**
     * Gets all HTTP headers
     * @return array
     */
    public function headers() {
        
        return $this->headers;
    }
    
    /**
     * Gets an HTTP header value if exists
     * @param string $name
     * @return string
     */
    public function header($name) {
        
        return (isset($this->headers[$name])) ? $this->headers[$name] : '';
    }
    
    /**
     * Verifies if a request parameter is set
     * @param type $parameter
     * @param boolean $emptyIsValid
     * @return boolean
     */
    private function hasParameter($parameter, $emptyIsValid) {
{'fraction_non_alphanumeric': 0.12860192102454643, 'fraction_numerical': 0.0010672358591248667, 'mean_word_length': 1.4770925110132158, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 2, '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': '5131730', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1524, 'n_words': 369}