[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

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


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