[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/web-auth/cose-lib/src/Algorithm/ -> Manager.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 Cose\Algorithm;
  15  
  16  use Assert\Assertion;
  17  
  18  class Manager
  19  {
  20      /**
  21       * @var Algorithm[]
  22       */
  23      private $algorithms = [];
  24  
  25      public function add(Algorithm $algorithm): void
  26      {
  27          $identifier = $algorithm::identifier();
  28          $this->algorithms[$identifier] = $algorithm;
  29      }
  30  
  31      /**
  32       * @deprecated Will be removed in v3.0. Please use all() instead
  33       */
  34      public function getAlgorithms(): iterable
  35      {
  36          yield from $this->algorithms;
  37      }
  38  
  39      public function list(): iterable
  40      {
  41          yield from array_keys($this->algorithms);
  42      }
  43  
  44      /**
  45       * @return Algorithm[]
  46       */
  47      public function all(): iterable
  48      {
  49          yield from $this->algorithms;
  50      }
  51  
  52      public function has(int $identifier): bool
  53      {
  54          return \array_key_exists($identifier, $this->algorithms);
  55      }
  56  
  57      public function get(int $identifier): Algorithm
  58      {
  59          Assertion::true($this->has($identifier), 'Unsupported algorithm');
  60  
  61          return $this->algorithms[$identifier];
  62      }
  63  }


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