@@ -38,7 +38,9 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | protected function __construct(array $headers = []){ |
| 40 | 40 | |
| 41 | - if(count($headers) === 0 ) return; |
|
| 41 | + if(count($headers) === 0 ) { |
|
| 42 | + return; |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | $alg = @$headers[JSONWebKeyParameters::Algorithm]; |
| 44 | 46 | $this->setAlgorithm($alg); |
@@ -80,8 +82,9 @@ discard block |
||
| 80 | 82 | */ |
| 81 | 83 | public function setId($kid) |
| 82 | 84 | { |
| 83 | - if(!empty($kid)) |
|
| 84 | - $this->set[JSONWebKeyParameters::KeyId] = new JsonValue($kid); |
|
| 85 | + if(!empty($kid)) { |
|
| 86 | + $this->set[JSONWebKeyParameters::KeyId] = new JsonValue($kid); |
|
| 87 | + } |
|
| 85 | 88 | return $this; |
| 86 | 89 | } |
| 87 | 90 | |
@@ -92,8 +95,9 @@ discard block |
||
| 92 | 95 | */ |
| 93 | 96 | public function setAlgorithm($alg) |
| 94 | 97 | { |
| 95 | - if(!in_array($alg, JSONWebSignatureAndEncryptionAlgorithms::$header_location_alg)) |
|
| 96 | - throw new InvalidJWKAlgorithm (sprintf('alg %s', $alg)); |
|
| 98 | + if(!in_array($alg, JSONWebSignatureAndEncryptionAlgorithms::$header_location_alg)) { |
|
| 99 | + throw new InvalidJWKAlgorithm (sprintf('alg %s', $alg)); |
|
| 100 | + } |
|
| 97 | 101 | |
| 98 | 102 | $this->set[JSONWebKeyParameters::Algorithm] = new StringOrURI($alg); |
| 99 | 103 | return $this; |
@@ -106,9 +110,12 @@ discard block |
||
| 106 | 110 | */ |
| 107 | 111 | public function setKeyUse($use) |
| 108 | 112 | { |
| 109 | - if(empty($use)) return $this; |
|
| 110 | - if(!in_array($use, JSONWebKeyPublicKeyUseValues::$valid_uses)) |
|
| 111 | - throw new InvalidJWKUseException(sprintf('use %s', $use)); |
|
| 113 | + if(empty($use)) { |
|
| 114 | + return $this; |
|
| 115 | + } |
|
| 116 | + if(!in_array($use, JSONWebKeyPublicKeyUseValues::$valid_uses)) { |
|
| 117 | + throw new InvalidJWKUseException(sprintf('use %s', $use)); |
|
| 118 | + } |
|
| 112 | 119 | |
| 113 | 120 | $this->set[JSONWebKeyParameters::PublicKeyUse] = new StringOrURI($use); |
| 114 | 121 | return $this; |
@@ -121,8 +128,9 @@ discard block |
||
| 121 | 128 | */ |
| 122 | 129 | public function setType($type) |
| 123 | 130 | { |
| 124 | - if(!in_array($type, JSONWebKeyTypes::$valid_keys_set)) |
|
| 125 | - throw new InvalidJWKType(sprintf('use %s', $type)); |
|
| 131 | + if(!in_array($type, JSONWebKeyTypes::$valid_keys_set)) { |
|
| 132 | + throw new InvalidJWKType(sprintf('use %s', $type)); |
|
| 133 | + } |
|
| 126 | 134 | |
| 127 | 135 | $this->set[JSONWebKeyParameters::KeyType] = new StringOrURI($type); |
| 128 | 136 | return $this; |
@@ -48,7 +48,9 @@ |
||
| 48 | 48 | */ |
| 49 | 49 | static public function deserialize($input){ |
| 50 | 50 | $parts = explode(IBasicJWT::SegmentSeparator, $input); |
| 51 | - if (count($parts) !== 5) throw new JWEInvalidCompactFormatException; |
|
| 51 | + if (count($parts) !== 5) { |
|
| 52 | + throw new JWEInvalidCompactFormatException; |
|
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | $header = JWEJOSEHeaderSerializer::deserialize($parts[0]); |
| 54 | 56 | $enc_cek = JWTRawSerializer::deserialize($parts[1]); |
@@ -39,7 +39,9 @@ |
||
| 39 | 39 | |
| 40 | 40 | $this->file = new X509(); |
| 41 | 41 | $this->info = $this->file->loadX509($pem); |
| 42 | - if($this->info === false) throw new InvalidX509CertificateException($pem); |
|
| 42 | + if($this->info === false) { |
|
| 43 | + throw new InvalidX509CertificateException($pem); |
|
| 44 | + } |
|
| 43 | 45 | $this->original_pem = $pem; |
| 44 | 46 | } |
| 45 | 47 | |
@@ -45,12 +45,15 @@ |
||
| 45 | 45 | $this->pem_format = $pem_format; |
| 46 | 46 | $this->rsa_imp = new RSA(); |
| 47 | 47 | |
| 48 | - if(!empty($password)) |
|
| 49 | - $this->rsa_imp->setPassword($password); |
|
| 48 | + if(!empty($password)) { |
|
| 49 | + $this->rsa_imp->setPassword($password); |
|
| 50 | + } |
|
| 50 | 51 | |
| 51 | 52 | $res = $this->rsa_imp->loadKey($this->pem_format, RSA::PRIVATE_FORMAT_PKCS1); |
| 52 | 53 | |
| 53 | - if(!$res) throw new RSABadPEMFormat(sprintf('pem %s',$pem_format )); |
|
| 54 | + if(!$res) { |
|
| 55 | + throw new RSABadPEMFormat(sprintf('pem %s',$pem_format )); |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | $this->n = $this->rsa_imp->modulus; |
| 56 | 59 | } |