[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/willdurand/negotiation/src/Negotiation/ -> AcceptLanguage.php (source)

   1  <?php
   2  
   3  namespace Negotiation;
   4  
   5  use Negotiation\Exception\InvalidLanguage;
   6  
   7  final class AcceptLanguage extends BaseAccept implements AcceptHeader
   8  {
   9      private $language;
  10      private $script;
  11      private $region;
  12  
  13      public function __construct($value)
  14      {
  15          parent::__construct($value);
  16  
  17          $parts = explode('-', $this->type);
  18  
  19          if (2 === count($parts)) {
  20              $this->language = $parts[0];
  21              $this->region   = $parts[1];
  22          } elseif (1 === count($parts)) {
  23              $this->language = $parts[0];
  24          } elseif (3 === count($parts)) {
  25              $this->language = $parts[0];
  26              $this->script   = $parts[1];
  27              $this->region   = $parts[2];
  28          } else {
  29              // TODO: this part is never reached...
  30              throw new InvalidLanguage();
  31          }
  32      }
  33  
  34      /**
  35       * @return string
  36       */
  37      public function getSubPart()
  38      {
  39          return $this->region;
  40      }
  41  
  42      /**
  43       * @return string
  44       */
  45      public function getBasePart()
  46      {
  47          return $this->language;
  48      }
  49  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer