[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/spomky-labs/cbor-php/src/Tag/ -> Base64UrlEncodingTag.php (source)

   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  /*
   6   * The MIT License (MIT)
   7   *
   8   * Copyright (c) 2018-2020 Spomky-Labs
   9   *
  10   * This software may be modified and distributed under the terms
  11   * of the MIT license.  See the LICENSE file for details.
  12   */
  13  
  14  namespace CBOR\Tag;
  15  
  16  use Base64Url\Base64Url;
  17  use CBOR\ByteStringObject;
  18  use CBOR\ByteStringWithChunkObject;
  19  use CBOR\CBORObject;
  20  use CBOR\TagObject as Base;
  21  use CBOR\TextStringObject;
  22  use CBOR\TextStringWithChunkObject;
  23  use InvalidArgumentException;
  24  
  25  final class Base64UrlEncodingTag extends Base
  26  {
  27      public static function getTagId(): int
  28      {
  29          return 21;
  30      }
  31  
  32      public static function createFromLoadedData(int $additionalInformation, ?string $data, CBORObject $object): Base
  33      {
  34          return new self($additionalInformation, $data, $object);
  35      }
  36  
  37      public static function create(CBORObject $object): Base
  38      {
  39          if (!$object instanceof ByteStringObject && !$object instanceof ByteStringWithChunkObject && !$object instanceof TextStringObject && !$object instanceof TextStringWithChunkObject) {
  40              throw new InvalidArgumentException('This tag only accepts Byte String, Infinite Byte String, Text String or Infinite Text String objects.');
  41          }
  42  
  43          return new self(21, null, $object);
  44      }
  45  
  46      public function getNormalizedData(bool $ignoreTags = false)
  47      {
  48          if ($ignoreTags) {
  49              return $this->object->getNormalizedData($ignoreTags);
  50          }
  51  
  52          if (!$this->object instanceof ByteStringObject && !$this->object instanceof ByteStringWithChunkObject && !$this->object instanceof TextStringObject && !$this->object instanceof TextStringWithChunkObject) {
  53              return $this->object->getNormalizedData($ignoreTags);
  54          }
  55  
  56          return Base64Url::decode($this->object->getNormalizedData($ignoreTags));
  57      }
  58  }


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