[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/lcobucci/jwt/src/Signer/Key/ -> InMemory.php (source)

   1  <?php
   2  
   3  namespace Lcobucci\JWT\Signer\Key;
   4  
   5  use Lcobucci\JWT\Encoding\CannotDecodeContent;
   6  use Lcobucci\JWT\Signer\Key;
   7  
   8  use function base64_decode;
   9  
  10  final class InMemory extends Key
  11  {
  12      /**
  13       * @param string $contents
  14       * @param string $passphrase
  15       *
  16       * @return self
  17       */
  18      public static function plainText($contents, $passphrase = '')
  19      {
  20          return new self($contents, $passphrase);
  21      }
  22  
  23      /**
  24       * @param string $contents
  25       * @param string $passphrase
  26       *
  27       * @return self
  28       */
  29      public static function base64Encoded($contents, $passphrase = '')
  30      {
  31          $decoded = base64_decode($contents, true);
  32  
  33          if ($decoded === false) {
  34              throw CannotDecodeContent::invalidBase64String();
  35          }
  36  
  37          return new self($decoded, $passphrase);
  38      }
  39  
  40      /**
  41       * @param string $path
  42       * @param string $passphrase
  43       *
  44       * @return InMemory
  45       *
  46       * @throws FileCouldNotBeRead
  47       */
  48      public static function file($path, $passphrase = '')
  49      {
  50          return new self('file://' . $path, $passphrase);
  51      }
  52  }


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