[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/web-auth/metadata-service/src/ -> SingleMetadata.php (source)

   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  /*
   6   * The MIT License (MIT)
   7   *
   8   * Copyright (c) 2014-2019 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 Webauthn\MetadataService;
  15  
  16  use Assert\Assertion;
  17  
  18  class SingleMetadata
  19  {
  20      /**
  21       * @var MetadataStatement
  22       */
  23      private $statement;
  24      /**
  25       * @var string
  26       */
  27      private $data;
  28      /**
  29       * @var bool
  30       */
  31      private $isBare64Encoded;
  32  
  33      public function __construct(string $data, bool $isBare64Encoded)
  34      {
  35          $this->data = $data;
  36          $this->isBare64Encoded = $isBare64Encoded;
  37      }
  38  
  39      public function getMetadataStatement(): MetadataStatement
  40      {
  41          if (null === $this->statement) {
  42              $json = $this->data;
  43              if ($this->isBare64Encoded) {
  44                  $json = base64_decode($this->data, true);
  45                  Assertion::string($json, 'Unable to decode the data');
  46              }
  47              $statement = json_decode($json, true);
  48              Assertion::eq(JSON_ERROR_NONE, json_last_error(), 'Unable to decode the data');
  49              $this->statement = MetadataStatement::createFromArray($statement);
  50          }
  51  
  52          return $this->statement;
  53      }
  54  }


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