@@ -75,8 +75,9 @@ |
||
75 | 75 | { |
76 | 76 | list($header, $payload, $signature) = JWTSerializer::deserialize($compact_serialization); |
77 | 77 | |
78 | - if(!($payload instanceof IJWTClaimSet)) |
|
79 | - throw new \RuntimeException('Invalid payload type!'); |
|
78 | + if(!($payload instanceof IJWTClaimSet)) { |
|
79 | + throw new \RuntimeException('Invalid payload type!'); |
|
80 | + } |
|
80 | 81 | |
81 | 82 | $jwt = new UnsecuredJWT($payload); |
82 | 83 | $jwt->header = $header; |
@@ -43,7 +43,9 @@ |
||
43 | 43 | $type = @RegisteredJOSEHeaderNames::$registered_basic_headers_set_types[$header_name]; |
44 | 44 | if(!is_null($value)) |
45 | 45 | { |
46 | - if(is_null($type)) continue; |
|
46 | + if(is_null($type)) { |
|
47 | + continue; |
|
48 | + } |
|
47 | 49 | $class = new \ReflectionClass($type); |
48 | 50 | $value = $class->newInstanceArgs(array($value)); |
49 | 51 | } |
@@ -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 | } |