99
1010class OidcJwtSigningKey
1111{
12- /**
13- * @var PublicKey
14- */
15- protected $ key ;
12+ protected PublicKey $ key ;
1613
1714 /**
1815 * Can be created either from a JWK parameter array or local file path to load a certificate from.
1916 * Examples:
2017 * 'file:///var/www/cert.pem'
2118 * ['kty' => 'RSA', 'alg' => 'RS256', 'n' => 'abc123...'].
2219 *
23- * @param array|string $jwkOrKeyPath
24- *
2520 * @throws OidcInvalidKeyException
2621 */
27- public function __construct ($ jwkOrKeyPath )
22+ public function __construct (array | string $ jwkOrKeyPath )
2823 {
2924 if (is_array ($ jwkOrKeyPath )) {
3025 $ this ->loadFromJwkArray ($ jwkOrKeyPath );
31- } elseif (is_string ($ jwkOrKeyPath) && strpos ( $ jwkOrKeyPath , 'file:// ' ) === 0 ) {
26+ } elseif (str_starts_with ($ jwkOrKeyPath , 'file:// ' )) {
3227 $ this ->loadFromPath ($ jwkOrKeyPath );
3328 } else {
3429 throw new OidcInvalidKeyException ('Unexpected type of key value provided ' );
@@ -38,7 +33,7 @@ public function __construct($jwkOrKeyPath)
3833 /**
3934 * @throws OidcInvalidKeyException
4035 */
41- protected function loadFromPath (string $ path )
36+ protected function loadFromPath (string $ path ): void
4237 {
4338 try {
4439 $ key = PublicKeyLoader::load (
@@ -58,7 +53,7 @@ protected function loadFromPath(string $path)
5853 /**
5954 * @throws OidcInvalidKeyException
6055 */
61- protected function loadFromJwkArray (array $ jwk )
56+ protected function loadFromJwkArray (array $ jwk ): void
6257 {
6358 // 'alg' is optional for a JWK, but we will still attempt to validate if
6459 // it exists otherwise presume it will be compatible.
@@ -82,7 +77,7 @@ protected function loadFromJwkArray(array $jwk)
8277 throw new OidcInvalidKeyException ('A "n" parameter on the provided key is expected ' );
8378 }
8479
85- $ n = strtr ($ jwk ['n ' ] ?? '' , '-_ ' , '+/ ' );
80+ $ n = strtr ($ jwk ['n ' ], '-_ ' , '+/ ' );
8681
8782 try {
8883 $ key = PublicKeyLoader::load ([
0 commit comments