<commit_before><?php

namespace Phug\Util;

use Exception;
use Throwable;

class SandBox
{
    /**
     * @var mixed
     */
    private $result;

    /**
     * @var Throwable
     */
    private $throwable;

    public function __construct(callable $action)
    {
        // @codeCoverageIgnoreStart
        try {
            $this->result = $action();
        } catch (Throwable $throwable) { // PHP 7
            $this->throwable = $throwable;
        } catch (Exception $exception) { // PHP 5
            $this->throwable = $exception;
        }
        // @codeCoverageIgnoreEnd
    }

    /**
     * @return mixed
     */
    public function getResult()
    {
        return $this->result;
    }

    /**
     * @return Throwable
     */
    public function getThrowable()
    {
        return $this->throwable;
    }
}<commit_msg>Sandbox catch now also the buffer output<commit_after><?php

namespace Phug\Util;

use Exception;
use Throwable;

class SandBox
{
    /**
     * @var mixed
     */
    private $result;

    /**
     * @var string
     */
    private $buffer;

    /**
     * @var Throwable
     */
    private $throwable;

    public function __construct(callable $action)
    {
        ob_start();
        // @codeCoverageIgnoreStart
        try {
            $this->result = $action();
        } catch (Throwable $throwable) { // PHP 7
            $this->throwable = $throwable;
        } catch (Exception $exception) { // PHP 5
            $this->throwable = $exception;
        }
        // @codeCoverageIgnoreEnd
        $this->buffer = ob_get_contents();
        ob_end_clean();
    }

    /**
     * @return mixed
     */
    public function getResult()
    {
        return $this->result;
    }

    /**
     * @return Throwable
     */
    public function getThrowable()
    {
        return $this->throwable;
    }

    /**
     * @return string
     */
    public function getBuffer()
    {
        return $this->buffer;
    }

    public function outputBuffer()
    {
        echo $this->buffer;

        $this->buffer = '';
    }
}
{'fraction_non_alphanumeric': 0.12784503631961258, 'fraction_numerical': 0.001937046004842615, 'mean_word_length': 1.6251588310038119, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '1847415', 'n_tokens_mistral': 630, 'n_tokens_neox': 609, 'n_words': 135}