%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/graphicd/www/vebto/vendor/willdurand/negotiation/src/Negotiation/
Upload File :
Create Path :
Current File : /home/graphicd/www/vebto/vendor/willdurand/negotiation/src/Negotiation/LanguageNegotiator.php

<?php

namespace Negotiation;

class LanguageNegotiator extends AbstractNegotiator
{
    /**
     * {@inheritdoc}
     */
    protected function acceptFactory($accept)
    {
        return new AcceptLanguage($accept);
    }

    /**
     * {@inheritdoc}
     */
    protected function match(AcceptHeader $acceptLanguage, AcceptHeader $priority, $index)
    {
        if (!$acceptLanguage instanceof AcceptLanguage || !$priority instanceof AcceptLanguage) {
            return null;
        }

        $ab = $acceptLanguage->getBasePart();
        $pb = $priority->getBasePart();

        $as = $acceptLanguage->getSubPart();
        $ps = $priority->getSubPart();

        $baseEqual = !strcasecmp($ab, $pb);
        $subEqual  = !strcasecmp($as, $ps);

        if (($ab == '*' || $baseEqual) && ($as === null || $subEqual)) {
            $score = 10 * $baseEqual + $subEqual;

            return new AcceptMatch($acceptLanguage->getQuality() * $priority->getQuality(), $score, $index);
        }

        return null;
    }
}

Zerion Mini Shell 1.0