[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/spomky-labs/cbor-php/src/Tag/ -> PositiveBigIntegerTag.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 CBOR\ByteStringObject;
  17  use CBOR\CBORObject;
  18  use CBOR\TagObject as Base;
  19  use CBOR\Utils;
  20  use InvalidArgumentException;
  21  
  22  final class PositiveBigIntegerTag extends Base
  23  {
  24      public static function getTagId(): int
  25      {
  26          return 2;
  27      }
  28  
  29      public static function createFromLoadedData(int $additionalInformation, ?string $data, CBORObject $object): Base
  30      {
  31          return new self($additionalInformation, $data, $object);
  32      }
  33  
  34      public static function create(CBORObject $object): Base
  35      {
  36          if (!$object instanceof ByteStringObject) {
  37              throw new InvalidArgumentException('This tag only accepts a Byte String object.');
  38          }
  39  
  40          return new self(2, null, $object);
  41      }
  42  
  43      public function getNormalizedData(bool $ignoreTags = false)
  44      {
  45          if ($ignoreTags) {
  46              return $this->object->getNormalizedData($ignoreTags);
  47          }
  48  
  49          if (!$this->object instanceof ByteStringObject) {
  50              return $this->object->getNormalizedData($ignoreTags);
  51          }
  52  
  53          return Utils::hexToString($this->object->getValue());
  54      }
  55  }


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