<commit_before><?php
/**
 * This file is part of SoloProyectos common library.
 *
 * @author  <NAME> <<EMAIL>>
 * @license https://github.com/soloproyectos-php/http-controller/blob/master/LICENSE The MIT License (MIT)
 * @link    https://github.com/soloproyectos-php/http-controllers
 */
namespace soloproyectos\http;
use \Exception;
use soloproyectos\http\exception\HttpException;
use soloproyectos\http\HttpController;

/**
 * Abstract base class of views.
 *
 * @package Admin\View
 * @author  Axis-Studios <<EMAIL>>
 * @license Proprietary License
 * @link    https://github.com/AxisStudios/syntheticpictures-admin
 */
abstract class HttpView
{
    /**
     * HTTP Controller.
     * @var HttpController
     */
    protected $controller = null;
    
    /**
     * Constructor.
     * 
     * @param HttpController $controller HTTP Controller
     */
    public function __construct($controller)
    {
        $this->controller = $controller;
    }
    
    /**
     * Gets the document.
     * 
     * @return mixed
     */
    abstract public function getDocument();
    
    /**
     * Makes the document.
     * 
     * This method captures any error thrown by the controller and appends it to the request header.
     * 
     * @return mixed
     */
    public function document()
    {
        $ret = "";
        
        // processes the request
        $exception = null;
        try {
            $this->controller->apply();
        } catch (Exception $e) {
            $exception = $e;
        }
        
        // gets the document body
        if ($exception === null || $exception instanceof HttpException) {
            try {
                $ret = $this->getDocument();
            } catch (Exception $e) {
                $exception = $e;
            }
        }
        
        // prepends the error message
        $message = "";
        if ($exception !== null) {
            $code = $exception instanceof HttpException? "400": "500";
            $message = $exception->getMessage();
            header("HTTP/1.0 $code $message");
        }
        
        return $ret;
    }
}
<commit_msg>replace HttpException by HttpClientException<commit_after><?php
/**
 * This file is part of SoloProyectos common library.
 *
 * @author  <NAME> <<EMAIL>>
 * @license https://github.com/soloproyectos-php/http-controller/blob/master/LICENSE The MIT License (MIT)
 * @link    https://github.com/soloproyectos-php/http-controllers
 */
namespace soloproyectos\http;
use \Exception;
use soloproyectos\http\exception\HttpClientException;
use soloproyectos\http\HttpController;

/**
 * Abstract base class of views.
 *
 * @package Admin\View
 * @author  Axis-Studios <<EMAIL>>
 * @license Proprietary License
 * @link    https://github.com/AxisStudios/syntheticpictures-admin
 */
abstract class HttpView
{
    /**
     * HTTP Controller.
     * @var HttpController
     */
    protected $controller = null;
    
    /**
     * Constructor.
     * 
     * @param HttpController $controller HTTP Controller
     */
    public function __construct($controller)
    {
        $this->controller = $controller;
    }
    
    /**
     * Gets the document.
     * 
     * @return mixed
     */
    abstract public function getDocument();
    
    /**
     * Makes the document.
     * 
     * This method captures any error thrown by the controller and appends it to the request header.
     * 
     * @return mixed
     */
    public function document()
    {
        $ret = "";
        
        // processes the request
        $exception = null;
        try {
            $this->controller->apply();
        } catch (Exception $e) {
            $exception = $e;
        }
        
        // gets the document body
        if ($exception === null || $exception instanceof HttpClientException) {
            try {
                $ret = $this->getDocument();
            } catch (Exception $e) {
                $exception = $e;
            }
        }
        
        // prepends the error message
        $message = "";
        if ($exception !== null) {
            $code = $exception instanceof HttpClientException? "400": "500";
            $message = $exception->getMessage();
            header("HTTP/1.0 $code $message");
        }
        
        return $ret;
    }
}

{'fraction_non_alphanumeric': 0.12000933924819052, 'fraction_numerical': 0.0037356992762082653, 'mean_word_length': 1.8751677852348994, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 23, 'https://': 6, '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': '4700749', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1177, 'n_words': 301}