Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
1 <?php 2 3 namespace Firebase\JWT; 4 5 use InvalidArgumentException; 6 use OpenSSLAsymmetricKey; 7 8 class Key 9 { 10 /** @var string $algorithm */ 11 private $algorithm; 12 13 /** @var string|resource|OpenSSLAsymmetricKey $keyMaterial */ 14 private $keyMaterial; 15 16 /** 17 * @param string|resource|OpenSSLAsymmetricKey $keyMaterial 18 * @param string $algorithm 19 */ 20 public function __construct($keyMaterial, $algorithm) 21 { 22 if ( 23 !is_string($keyMaterial) 24 && !is_resource($keyMaterial) 25 && !$keyMaterial instanceof OpenSSLAsymmetricKey 26 ) { 27 throw new InvalidArgumentException('Type error: $keyMaterial must be a string, resource, or OpenSSLAsymmetricKey'); 28 } 29 30 if (empty($keyMaterial)) { 31 throw new InvalidArgumentException('Type error: $keyMaterial must not be empty'); 32 } 33 34 if (!is_string($algorithm)|| empty($keyMaterial)) { 35 throw new InvalidArgumentException('Type error: $algorithm must be a string'); 36 } 37 38 $this->keyMaterial = $keyMaterial; 39 $this->algorithm = $algorithm; 40 } 41 42 /** 43 * Return the algorithm valid for this key 44 * 45 * @return string 46 */ 47 public function getAlgorithm() 48 { 49 return $this->algorithm; 50 } 51 52 /** 53 * @return string|resource|OpenSSLAsymmetricKey 54 */ 55 public function getKeyMaterial() 56 { 57 return $this->keyMaterial; 58 } 59 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body