@@ -29,12 +29,12 @@ discard block |
||
| 29 | 29 | * @param mixed $content |
| 30 | 30 | * @return IJWSPayloadSpec |
| 31 | 31 | */ |
| 32 | - public static function build($content){ |
|
| 32 | + public static function build($content) { |
|
| 33 | 33 | |
| 34 | - if($content instanceof IJWTClaimSet){ |
|
| 34 | + if ($content instanceof IJWTClaimSet) { |
|
| 35 | 35 | return new _JWSPayloadClaimSetSpec($content); |
| 36 | 36 | } |
| 37 | - else{ |
|
| 37 | + else { |
|
| 38 | 38 | return new _JWSPayloadRawSpec($content); |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | /** |
| 57 | 57 | * @param IJWTClaimSet $claim_set |
| 58 | 58 | */ |
| 59 | - public function __construct(IJWTClaimSet $claim_set){ |
|
| 59 | + public function __construct(IJWTClaimSet $claim_set) { |
|
| 60 | 60 | $this->claim_set = $claim_set; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | /** |
| 102 | 102 | * @param string $raw |
| 103 | 103 | */ |
| 104 | - public function __construct($raw){ |
|
| 104 | + public function __construct($raw) { |
|
| 105 | 105 | $this->raw = $raw; |
| 106 | 106 | } |
| 107 | 107 | |
@@ -72,5 +72,5 @@ |
||
| 72 | 72 | * @param string $signature |
| 73 | 73 | * @return IJWS |
| 74 | 74 | */ |
| 75 | - static public function fromHeaderClaimsAndSignature(IJOSEHeader $header, IJWSPayloadSpec $payload = null , $signature = ''); |
|
| 75 | + static public function fromHeaderClaimsAndSignature(IJOSEHeader $header, IJWSPayloadSpec $payload = null, $signature = ''); |
|
| 76 | 76 | } |
| 77 | 77 | \ No newline at end of file |
@@ -29,7 +29,7 @@ |
||
| 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) throw new \RuntimeException('you must pass len as arg!'); |
|
| 33 | 33 | $byte_len = func_get_arg(0); |
| 34 | 34 | return ByteUtil::randomBytes($byte_len); |
| 35 | 35 | } |
@@ -32,18 +32,18 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | private $services = array(); |
| 34 | 34 | |
| 35 | - private function __construct(){ |
|
| 35 | + private function __construct() { |
|
| 36 | 36 | |
| 37 | 37 | $this->services[self::RandomNumberGeneratorService] = new RandomNumberGeneratorService; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - private function __clone(){} |
|
| 40 | + private function __clone() {} |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @return Utils_Registry |
| 44 | 44 | */ |
| 45 | - public static function getInstance(){ |
|
| 46 | - if(!is_object(self::$instance)){ |
|
| 45 | + public static function getInstance() { |
|
| 46 | + if (!is_object(self::$instance)) { |
|
| 47 | 47 | self::$instance = new Utils_Registry(); |
| 48 | 48 | } |
| 49 | 49 | return self::$instance; |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | * @param string $service_name |
| 54 | 54 | * @return null|IService |
| 55 | 55 | */ |
| 56 | - public function get($service_name){ |
|
| 57 | - if(!array_key_exists($service_name, $this->services)) |
|
| 56 | + public function get($service_name) { |
|
| 57 | + if (!array_key_exists($service_name, $this->services)) |
|
| 58 | 58 | throw new \InvalidArgumentException('unknown service!'); |
| 59 | 59 | |
| 60 | 60 | return $this->services[$service_name]; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @param IService $service |
| 66 | 66 | * @return $this |
| 67 | 67 | */ |
| 68 | - public function add($service_name, IService $service){ |
|
| 68 | + public function add($service_name, IService $service) { |
|
| 69 | 69 | $this->services[$service_name] = $service; |
| 70 | 70 | return $this; |
| 71 | 71 | } |
@@ -42,18 +42,18 @@ |
||
| 42 | 42 | $segments = explode(IBasicJWT::SegmentSeparator, $compact_serialization); |
| 43 | 43 | // JWSs have three segments separated by two period ('.') characters. |
| 44 | 44 | // JWEs have five segments separated by four period ('.') characters. |
| 45 | - switch(count($segments)) |
|
| 45 | + switch (count($segments)) |
|
| 46 | 46 | { |
| 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])) |
|
| 50 | + if ($header->getAlgorithm()->getString() === 'none' && empty($segments[2])) |
|
| 51 | 51 | return UnsecuredJWT::fromCompactSerialization($compact_serialization); |
| 52 | - return JWSFactory::build( new JWS_CompactFormatSpecification($compact_serialization) ); |
|
| 52 | + return JWSFactory::build(new JWS_CompactFormatSpecification($compact_serialization)); |
|
| 53 | 53 | break; |
| 54 | 54 | case 5: |
| 55 | 55 | // JWE |
| 56 | - return JWEFactory::build( new JWE_CompactFormatSpecification($compact_serialization) ); |
|
| 56 | + return JWEFactory::build(new JWE_CompactFormatSpecification($compact_serialization)); |
|
| 57 | 57 | break; |
| 58 | 58 | default: |
| 59 | 59 | throw new InvalidCompactSerializationException; |
@@ -29,14 +29,14 @@ |
||
| 29 | 29 | /** |
| 30 | 30 | * @param int|string|array|bool|IJsonObject $value |
| 31 | 31 | */ |
| 32 | - public function __construct($value){ |
|
| 32 | + public function __construct($value) { |
|
| 33 | 33 | $this->value = $value; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @return int|string|array|bool|IJsonObject |
| 38 | 38 | */ |
| 39 | - public function getValue(){ |
|
| 39 | + public function getValue() { |
|
| 40 | 40 | return $this->value; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | class StringOrURI extends JsonValue { |
| 27 | 27 | |
| 28 | - public function getString(){ |
|
| 28 | + public function getString() { |
|
| 29 | 29 | return (string)$this->value; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | * @throws \RuntimeException |
| 34 | 34 | * @return string |
| 35 | 35 | */ |
| 36 | - public function getUri(){ |
|
| 36 | + public function getUri() { |
|
| 37 | 37 | |
| 38 | - if($this->isString()) |
|
| 38 | + if ($this->isString()) |
|
| 39 | 39 | throw new \RuntimeException('current value is not an uri!'); |
| 40 | - if(filter_var($this->value, FILTER_VALIDATE_URL) === false) |
|
| 40 | + if (filter_var($this->value, FILTER_VALIDATE_URL) === false) |
|
| 41 | 41 | throw new \RuntimeException('current value is not an uri!'); |
| 42 | 42 | |
| 43 | 43 | return (string)$this->value; |
@@ -46,21 +46,21 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * @return bool |
| 48 | 48 | */ |
| 49 | - public function isString(){ |
|
| 49 | + public function isString() { |
|
| 50 | 50 | return !$this->isUri(); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * @return bool |
| 55 | 55 | */ |
| 56 | - public function isUri(){ |
|
| 56 | + public function isUri() { |
|
| 57 | 57 | return !(strstr($this->value, ':') === false); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | - public function getValue(){ |
|
| 63 | + public function getValue() { |
|
| 64 | 64 | return $this->isUri() ? $this->getUri() : $this->getString(); |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | \ No newline at end of file |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class JsonArray extends JsonValue implements \ArrayAccess { |
| 22 | 22 | |
| 23 | - public function __construct(array $values){ |
|
| 23 | + public function __construct(array $values) { |
|
| 24 | 24 | parent::__construct($values); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | unset($this->value[$offset]); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public function append($value){ |
|
| 48 | + public function append($value) { |
|
| 49 | 49 | array_push($this->value, $value); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | $input = $this->toArray(); |
| 59 | 59 | $json = json_encode($input); |
| 60 | - $json = str_replace('\/','/', $json); |
|
| 60 | + $json = str_replace('\/', '/', $json); |
|
| 61 | 61 | |
| 62 | 62 | if (function_exists('json_last_error') && $errno = json_last_error()) { |
| 63 | 63 | self::handleJsonError($errno); |
| 64 | - } elseif ($json === 'null' ) { |
|
| 64 | + } elseif ($json === 'null') { |
|
| 65 | 65 | throw new JsonParseException('Null resul with non-null input'); |
| 66 | 66 | } |
| 67 | 67 | return $json; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | throw new JsonParseException( |
| 82 | 82 | isset($messages[$errno]) |
| 83 | 83 | ? $messages[$errno] |
| 84 | - : 'Unknown JSON error: ' . $errno |
|
| 84 | + : 'Unknown JSON error: '.$errno |
|
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | $res = array(); |
| 94 | 94 | |
| 95 | - foreach($this->set as $key => $val){ |
|
| 96 | - if($val instanceof JsonValue){ |
|
| 95 | + foreach ($this->set as $key => $val) { |
|
| 96 | + if ($val instanceof JsonValue) { |
|
| 97 | 97 | $res[$key] = $val->getValue(); |
| 98 | - if($res[$key] instanceof JsonObject) |
|
| 98 | + if ($res[$key] instanceof JsonObject) |
|
| 99 | 99 | $res[$key] = $res[$key]->toArray(); |
| 100 | - if(is_array($res[$key])){ |
|
| 100 | + if (is_array($res[$key])) { |
|
| 101 | 101 | $res[$key] = $this->processArray($res[$key]); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | return $res; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - private function processArray($original){ |
|
| 109 | + private function processArray($original) { |
|
| 110 | 110 | $temp = array(); |
| 111 | - foreach($original as $k => $val){ |
|
| 112 | - if($val instanceof JsonObject) |
|
| 111 | + foreach ($original as $k => $val) { |
|
| 112 | + if ($val instanceof JsonObject) |
|
| 113 | 113 | $val = $val->toArray(); |
| 114 | 114 | $temp[$k] = $val; |
| 115 | 115 | } |