404

[ Avaa Bypassed ]




Upload:

Command:

botdev@3.145.175.141: ~ $
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\HttpFoundation;

/**
 * Represents an Accept-* header.
 *
 * An accept header is compound with a list of items,
 * sorted by descending quality.
 *
 * @author Jean-François Simon <contact@jfsimon.fr>
 */
class AcceptHeader
{
    /**
     * @var AcceptHeaderItem[]
     */
    private $items = array();

    /**
     * @var bool
     */
    private $sorted = true;

    /**
     * @param AcceptHeaderItem[] $items
     */
    public function __construct(array $items)
    {
        foreach ($items as $item) {
            $this->add($item);
        }
    }

    /**
     * Builds an AcceptHeader instance from a string.
     *
     * @param string $headerValue
     *
     * @return self
     */
    public static function fromString($headerValue)
    {
        $index = 0;

        return new self(array_map(function ($itemValue) use (&$index) {
            $item = AcceptHeaderItem::fromString($itemValue);
            $item->setIndex($index++);

            return $item;
        }, preg_split('/\s*(?:,*("[^"]+"),*|,*(\'[^\']+\'),*|,+)\s*/', $headerValue, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)));
    }

    /**
     * Returns header value's string representation.
     *
     * @return string
     */
    public function __toString()
    {
        return implode(',', $this->items);
    }

    /**
     * Tests if header has given value.
     *
     * @param string $value
     *
     * @return bool
     */
    public function has($value)
    {
        return isset($this->items[$value]);
    }

    /**
     * Returns given value's item, if exists.
     *
     * @param string $value
     *
     * @return AcceptHeaderItem|null
     */
    public function get($value)
    {
        return isset($this->items[$value]) ? $this->items[$value] : null;
    }

    /**
     * Adds an item.
     *
     * @return $this
     */
    public function add(AcceptHeaderItem $item)
    {
        $this->items[$item->getValue()] = $item;
        $this->sorted = false;

        return $this;
    }

    /**
     * Returns all items.
     *
     * @return AcceptHeaderItem[]
     */
    public function all()
    {
        $this->sort();

        return $this->items;
    }

    /**
     * Filters items on their value using given regex.
     *
     * @param string $pattern
     *
     * @return self
     */
    public function filter($pattern)
    {
        return new self(array_filter($this->items, function (AcceptHeaderItem $item) use ($pattern) {
            return preg_match($pattern, $item->getValue());
        }));
    }

    /**
     * Returns first item.
     *
     * @return AcceptHeaderItem|null
     */
    public function first()
    {
        $this->sort();

        return !empty($this->items) ? reset($this->items) : null;
    }

    /**
     * Sorts items by descending quality.
     */
    private function sort()
    {
        if (!$this->sorted) {
            uasort($this->items, function (AcceptHeaderItem $a, AcceptHeaderItem $b) {
                $qA = $a->getQuality();
                $qB = $b->getQuality();

                if ($qA === $qB) {
                    return $a->getIndex() > $b->getIndex() ? 1 : -1;
                }

                return $qA > $qB ? -1 : 1;
            });

            $this->sorted = true;
        }
    }
}

Filemanager

Name Type Size Permission Actions
Exception Folder 0755
File Folder 0755
Session Folder 0755
Tests Folder 0755
.gitignore File 34 B 0644
AcceptHeader.php File 3.46 KB 0644
AcceptHeaderItem.php File 4.58 KB 0644
ApacheRequest.php File 930 B 0644
BinaryFileResponse.php File 11.65 KB 0644
CHANGELOG.md File 8.21 KB 0644
Cookie.php File 7.87 KB 0644
ExpressionRequestMatcher.php File 1.33 KB 0644
FileBag.php File 3.91 KB 0644
HeaderBag.php File 8.79 KB 0644
IpUtils.php File 4.63 KB 0644
JsonResponse.php File 7.2 KB 0644
LICENSE File 1.04 KB 0644
ParameterBag.php File 5.86 KB 0644
README.md File 537 B 0644
RedirectResponse.php File 2.89 KB 0644
Request.php File 69.28 KB 0644
RequestMatcher.php File 4.35 KB 0644
RequestMatcherInterface.php File 687 B 0644
RequestStack.php File 2.3 KB 0644
Response.php File 37.02 KB 0644
ResponseHeaderBag.php File 9.8 KB 0644
ServerBag.php File 4.14 KB 0644
StreamedResponse.php File 3.24 KB 0644
composer.json File 958 B 0644
phpunit.xml.dist File 892 B 0644