<commit_before><?php

namespace Bootstrap\Exceptions;

use Exception;
use ErrorException;
use Symfony\Component\Debug\ExceptionHandler;
use Monolog\ErrorHandler as MonologErrorHandler;
use Symfony\Component\Debug\Exception\FlattenException;

class Handler extends Exception
{
    private $handler;

    private $function_name = 'handle';

    public function __construct($message = null, $code = null, $previous = null)
    {
        parent::__construct($message, $code, $previous);
    }

    /**
     * Handles fatal error, based on the lists
     */
    public function handleFatalError()
    {
        $error = error_get_last();

        if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
            $this->handleError(
                $error['type'],
                $error['message'],
                $error['file'],
                $error['line']
            );
        }
    }

    /**
     * Creates an error exception
     *
     * @param  [type] $num     error type e.g(E_PARSE | E_ERROR ...)
     * @param  [type] $str     error message
     * @param  [type] $file    the file affected by the error
     * @param  [type] $line    on what line affects
     * @param  [type] $context the contenxt
     */
    public function handleError($num, $str, $file, $line, $context = null)
    {
        $e = new ErrorException($str, 0, $num, $file, $line);

        $this->handleExceptionError(
            FlattenException::create($e)
        );
    }

    /**
     * Print outs a simple but useful debugging ui
     *
     * @param  FlattenException $e instanced exception based on FlattenException
     */
    public function handleExceptionError(Exception $e)
    {
        $this->render($e);
    }

    public function render($e)
    {
        (new ExceptionHandler($this->getDebugMode()))->sendPhpResponse($e);
    }

    /**
     * Processes the error, fatal and exceptions<commit_msg>removing the Exception instanced checking in the function<commit_after><?php

namespace Bootstrap\Exceptions;

use Exception;
use ErrorException;
use Symfony\Component\Debug\ExceptionHandler;
use Monolog\ErrorHandler as MonologErrorHandler;
use Symfony\Component\Debug\Exception\FlattenException;

class Handler extends Exception
{
    private $handler;

    private $function_name = 'handle';

    public function __construct($message = null, $code = null, $previous = null)
    {
        parent::__construct($message, $code, $previous);
    }

    /**
     * Handles fatal error, based on the lists
     */
    public function handleFatalError()
    {
        $error = error_get_last();

        if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
            $this->handleError(
                $error['type'],
                $error['message'],
                $error['file'],
                $error['line']
            );
        }
    }

    /**
     * Creates an error exception
     *
     * @param  [type] $num     error type e.g(E_PARSE | E_ERROR ...)
     * @param  [type] $str     error message
     * @param  [type] $file    the file affected by the error
     * @param  [type] $line    on what line affects
     * @param  [type] $context the contenxt
     */
    public function handleError($num, $str, $file, $line, $context = null)
    {
        $e = new ErrorException($str, 0, $num, $file, $line);

        $this->handleExceptionError(
            FlattenException::create($e)
        );
    }

    /**
     * Print outs a simple but useful debugging ui
     *
     * @param $e instanced exception based on FlattenException
     */
    public function handleExceptionError($e)
    {
        $this->render($e);
    }

    public function render($e)
    {
        (new ExceptionHandler($this->getDebugMode()))->sendPhpResponse($e);
    }

    /**
     * Processes the error, fatal and exceptions
{'fraction_non_alphanumeric': 0.12183789364997419, 'fraction_numerical': 0.0005162622612287042, 'mean_word_length': 2.3261802575107295, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '912883', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1103, 'n_words': 294}