HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/demo.sports-crowd.com/vendor/zircote/swagger-php/src/Pipeline.php
<?php declare(strict_types=1);

/**
 * @license Apache 2.0
 */

namespace OpenApi;

class Pipeline
{
    /**
     * @var array<callable>
     */
    protected $pipes = [];

    public function __construct(array $pipes = [])
    {
        $this->pipes = $pipes;
    }

    /**
     * @deprecated This will be removed in 5.0
     */
    public function pipes(): array
    {
        return $this->pipes;
    }

    public function add(callable $pipe): Pipeline
    {
        $this->pipes[] = $pipe;

        return $this;
    }

    /**
     * @param callable|class-string|null $pipe
     */
    public function remove($pipe = null, ?callable $matcher = null): Pipeline
    {
        if (!$pipe && !$matcher) {
            throw new OpenApiException('pipe or callable must not be empty');
        }

        // allow matching on class name in $pipe in a string
        if (is_string($pipe) && !$matcher) {
            $pipeClass = $pipe;
            $matcher = function ($pipe) use ($pipeClass) {
                return !$pipe instanceof $pipeClass;
            };
        }

        if ($matcher) {
            $tmp = [];
            foreach ($this->pipes as $pipe) {
                if ($matcher($pipe)) {
                    $tmp[] = $pipe;
                }
            }

            $this->pipes = $tmp;
        } else {
            if (false === ($key = array_search($pipe, $this->pipes, true))) {
                return $this;
            }

            unset($this->pipes[$key]);

            $this->pipes = array_values($this->pipes);
        }

        return $this;
    }

    /**
     * @param callable|class-string $matcher used to determine the position to insert
     *                                       either an `int` from a callable or, in the case of `$matcher` being
     *                                       a `class-string`, the position before the first pipe of that class
     */
    public function insert(callable $pipe, $matcher): Pipeline
    {
        if (is_string($matcher)) {
            $before = $matcher;
            $matcher = function (array $pipes) use ($before) {
                foreach ($pipes as $ii => $current) {
                    if ($current instanceof $before) {
                        return $ii;
                    }
                }

                return null;
            };
        }

        $index = $matcher($this->pipes);
        if (null === $index || $index < 0 || $index > count($this->pipes)) {
            throw new OpenApiException('Matcher result out of range');
        }

        array_splice($this->pipes, $index, 0, [$pipe]);

        return $this;
    }

    public function walk(callable $walker): Pipeline
    {
        foreach ($this->pipes as $pipe) {
            $walker($pipe);
        }

        return $this;
    }

    /**
     * @param mixed $payload
     *
     * @return mixed
     */
    public function process($payload)
    {
        foreach ($this->pipes as $pipe) {
            /** @deprecated null payload returned from pipe */
            $payload = $pipe($payload) ?: $payload;
        }

        return $payload;
    }
}