<commit_before><?php
/**
 * PHP Version 5.6.0
 *
 * @category Middleware
 * @package  Onion\Framework\Http
 * @author   <NAME> <<EMAIL>>
 * @license  MIT https://opensource.org/licenses/MIT
 * @link     https://github.com/phOnion/framework
 */
namespace Onion\Framework\Http\Middleware;

use Onion\Framework\Interfaces\Common\PrototypeObjectInterface;
use Onion\Framework\Interfaces\Middleware\FrameInterface;
use Onion\Framework\Interfaces\Middleware\MiddlewareInterface;
use Onion\Framework\Interfaces\Middleware\ServerMiddlewareInterface;
use Onion\Framework\Interfaces\Middleware\StackInterface;
use Psr\Http\Message;

class Pipe implements StackInterface, PrototypeObjectInterface
{
    /**
     * @var \SplFixedArray
     */
    protected $middleware;

    /**
     * Pipe constructor.
     *
     * @param MiddlewareInterface[]|ServerMiddlewareInterface[] $middleware
     */
    public function __construct(array $middleware = [])
    {
        try {
            $this->initialize($middleware);
        } catch (\InvalidArgumentException $ex) {
            // Constructor defaults to an empty array if omitted, will never happen
            // Note to self: Make sure to update the catch block in case the constructor changes
        }
    }

    public function handle(Message\RequestInterface $request)
    {
        return $this->process($request, null);
    }

    /**
     * @param Message\RequestInterface $request
     * @param FrameInterface           $frame
     *
     * @return Message\ResponseInterface
     * @throws \RuntimeException
     */
    public function process(Message\RequestInterface $request, FrameInterface $frame = null)
    {
        $stack = null;
        if (0 !== count($this->middleware)) {
            try {
                $this->middleware->rewind();
                while ($this->middleware->valid()) {
                    $stack = new Frame($this->middleware->current(), $stack);
                    $this->middleware->next();
                }
<commit_msg>Removed ugly try-catch block from the constructor<commit_after><?php
/**
 * PHP Version 5.6.0
 *
 * @category Middleware
 * @package  Onion\Framework\Http
 * @author   <NAME>rov <<EMAIL>>
 * @license  MIT https://opensource.org/licenses/MIT
 * @link     https://github.com/phOnion/framework
 */
namespace Onion\Framework\Http\Middleware;

use Onion\Framework\Interfaces\Common\PrototypeObjectInterface;
use Onion\Framework\Interfaces\Middleware\FrameInterface;
use Onion\Framework\Interfaces\Middleware\MiddlewareInterface;
use Onion\Framework\Interfaces\Middleware\ServerMiddlewareInterface;
use Onion\Framework\Interfaces\Middleware\StackInterface;
use Psr\Http\Message;

class Pipe implements StackInterface, PrototypeObjectInterface
{
    /**
     * @var \SplFixedArray
     */
    protected $middleware;

    /**
     * Pipe constructor.
     *
     * @param MiddlewareInterface[]|ServerMiddlewareInterface[] $middleware
     *
     * @throws \InvalidArgumentException if for some magical reason self::initialize fails
     */
    public function __construct(array $middleware = [])
    {
        $this->initialize($middleware);
    }

    public function handle(Message\RequestInterface $request)
    {
        return $this->process($request, null);
    }

    /**
     * @param Message\RequestInterface $request
     * @param FrameInterface           $frame
     *
     * @return Message\ResponseInterface
     * @throws \RuntimeException
     */
    public function process(Message\RequestInterface $request, FrameInterface $frame = null)
    {
        $stack = null;
        if (0 !== count($this->middleware)) {
            try {
                $this->middleware->rewind();
                while ($this->middleware->valid()) {
                    $stack = new Frame($this->middleware->current(), $stack);
                    $this->middleware->next();
                }

{'fraction_non_alphanumeric': 0.1166323377960865, 'fraction_numerical': 0.0020597322348094747, 'mean_word_length': 2.703527168732126, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, 'https://': 4, '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': '7234379', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1031, 'n_words': 219}