@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | if($spec instanceof IJWS_ParamsSpecification) |
| 43 | 43 | { |
| 44 | - if($spec->getKey()->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature) |
|
| 45 | - throw new InvalidJWKType |
|
| 44 | + if($spec->getKey()->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature) { |
|
| 45 | + throw new InvalidJWKType |
|
| 46 | 46 | ( |
| 47 | 47 | sprintf |
| 48 | 48 | ( |
@@ -50,9 +50,10 @@ discard block |
||
| 50 | 50 | $spec->getKey()->getKeyUse()->getString() |
| 51 | 51 | ) |
| 52 | 52 | ); |
| 53 | + } |
|
| 53 | 54 | |
| 54 | - if($spec->getAlg()->getString() !== $spec->getKey()->getAlgorithm()->getString()) |
|
| 55 | - throw new InvalidJWKAlgorithm |
|
| 55 | + if($spec->getAlg()->getString() !== $spec->getKey()->getAlgorithm()->getString()) { |
|
| 56 | + throw new InvalidJWKAlgorithm |
|
| 56 | 57 | ( |
| 57 | 58 | sprintf |
| 58 | 59 | ( |
@@ -61,6 +62,7 @@ discard block |
||
| 61 | 62 | $spec->getKey()->getAlgorithm()->getString() |
| 62 | 63 | ) |
| 63 | 64 | ); |
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | $header = new JOSEHeader |
| 66 | 68 | ( |
@@ -56,11 +56,13 @@ |
||
| 56 | 56 | */ |
| 57 | 57 | public function __construct(IJWK $key, StringOrURI $alg, $payload, $signature = ''){ |
| 58 | 58 | |
| 59 | - if(is_null($key)) |
|
| 60 | - throw new InvalidJWKType(); |
|
| 59 | + if(is_null($key)) { |
|
| 60 | + throw new InvalidJWKType(); |
|
| 61 | + } |
|
| 61 | 62 | |
| 62 | - if(is_null($payload)) |
|
| 63 | - throw new JWSInvalidPayloadException('missing payload'); |
|
| 63 | + if(is_null($payload)) { |
|
| 64 | + throw new JWSInvalidPayloadException('missing payload'); |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | $this->key = $key; |
| 66 | 68 | $this->alg = $alg; |
@@ -33,8 +33,7 @@ |
||
| 33 | 33 | |
| 34 | 34 | if($content instanceof IJWTClaimSet){ |
| 35 | 35 | return new _JWSPayloadClaimSetSpec($content); |
| 36 | - } |
|
| 37 | - else{ |
|
| 36 | + } else{ |
|
| 38 | 37 | return new _JWSPayloadRawSpec($content); |
| 39 | 38 | } |
| 40 | 39 | } |
@@ -29,7 +29,9 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | public function invoke() |
| 31 | 31 | { |
| 32 | - if(func_num_args() <= 0) throw new \RuntimeException('you must pass len as arg!'); |
|
| 32 | + if(func_num_args() <= 0) { |
|
| 33 | + throw new \RuntimeException('you must pass len as arg!'); |
|
| 34 | + } |
|
| 33 | 35 | $byte_len = func_get_arg(0); |
| 34 | 36 | return ByteUtil::randomBytes($byte_len); |
| 35 | 37 | } |
@@ -54,8 +54,9 @@ |
||
| 54 | 54 | * @return null|IService |
| 55 | 55 | */ |
| 56 | 56 | public function get($service_name){ |
| 57 | - if(!array_key_exists($service_name, $this->services)) |
|
| 58 | - throw new \InvalidArgumentException('unknown service!'); |
|
| 57 | + if(!array_key_exists($service_name, $this->services)) { |
|
| 58 | + throw new \InvalidArgumentException('unknown service!'); |
|
| 59 | + } |
|
| 59 | 60 | |
| 60 | 61 | return $this->services[$service_name]; |
| 61 | 62 | } |
@@ -47,8 +47,9 @@ |
||
| 47 | 47 | case 3: |
| 48 | 48 | // JWS or unsecured one |
| 49 | 49 | $header = JOSEHeaderSerializer::deserialize($segments[0]); |
| 50 | - if($header->getAlgorithm()->getString() === 'none' && empty($segments[2])) |
|
| 51 | - return UnsecuredJWT::fromCompactSerialization($compact_serialization); |
|
| 50 | + if($header->getAlgorithm()->getString() === 'none' && empty($segments[2])) { |
|
| 51 | + return UnsecuredJWT::fromCompactSerialization($compact_serialization); |
|
| 52 | + } |
|
| 52 | 53 | return JWSFactory::build( new JWS_CompactFormatSpecification($compact_serialization) ); |
| 53 | 54 | break; |
| 54 | 55 | case 5: |
@@ -35,10 +35,12 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | public function getUri(){ |
| 37 | 37 | |
| 38 | - if($this->isString()) |
|
| 39 | - throw new \RuntimeException('current value is not an uri!'); |
|
| 40 | - if(filter_var($this->value, FILTER_VALIDATE_URL) === false) |
|
| 41 | - throw new \RuntimeException('current value is not an uri!'); |
|
| 38 | + if($this->isString()) { |
|
| 39 | + throw new \RuntimeException('current value is not an uri!'); |
|
| 40 | + } |
|
| 41 | + if(filter_var($this->value, FILTER_VALIDATE_URL) === false) { |
|
| 42 | + throw new \RuntimeException('current value is not an uri!'); |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | return (string)$this->value; |
| 44 | 46 | } |
@@ -41,8 +41,9 @@ |
||
| 41 | 41 | |
| 42 | 42 | public function offsetUnset($offset) |
| 43 | 43 | { |
| 44 | - if ($this->offsetExists($offset)) |
|
| 45 | - unset($this->value[$offset]); |
|
| 44 | + if ($this->offsetExists($offset)) { |
|
| 45 | + unset($this->value[$offset]); |
|
| 46 | + } |
|
| 46 | 47 | } |
| 47 | 48 | |
| 48 | 49 | public function append($value){ |
@@ -95,8 +95,9 @@ discard block |
||
| 95 | 95 | foreach($this->set as $key => $val){ |
| 96 | 96 | if($val instanceof JsonValue){ |
| 97 | 97 | $res[$key] = $val->getValue(); |
| 98 | - if($res[$key] instanceof JsonObject) |
|
| 99 | - $res[$key] = $res[$key]->toArray(); |
|
| 98 | + if($res[$key] instanceof JsonObject) { |
|
| 99 | + $res[$key] = $res[$key]->toArray(); |
|
| 100 | + } |
|
| 100 | 101 | if(is_array($res[$key])){ |
| 101 | 102 | $res[$key] = $this->processArray($res[$key]); |
| 102 | 103 | } |
@@ -109,8 +110,9 @@ discard block |
||
| 109 | 110 | private function processArray($original){ |
| 110 | 111 | $temp = array(); |
| 111 | 112 | foreach($original as $k => $val){ |
| 112 | - if($val instanceof JsonObject) |
|
| 113 | - $val = $val->toArray(); |
|
| 113 | + if($val instanceof JsonObject) { |
|
| 114 | + $val = $val->toArray(); |
|
| 115 | + } |
|
| 114 | 116 | $temp[$k] = $val; |
| 115 | 117 | } |
| 116 | 118 | return $temp; |