@@ -41,15 +41,15 @@ |
||
| 41 | 41 | { |
| 42 | 42 | $url = $this->_options["url"]."?appId=".$this->_options["appid"]; |
| 43 | 43 | |
| 44 | - $url.= "¬ificationToken=".$notificationToken; |
|
| 44 | + $url .= "¬ificationToken=".$notificationToken; |
|
| 45 | 45 | |
| 46 | 46 | $output = file_get_contents($url); |
| 47 | - if (stripos($output, "not found")!==false) { |
|
| 47 | + if (stripos($output, "not found") !== false) { |
|
| 48 | 48 | $this->logger->error('Token Exchange failed and responded with: not found', ['full output' => $output]); |
| 49 | 49 | return false; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if (stripos($output, "error")!==false) { |
|
| 52 | + if (stripos($output, "error") !== false) { |
|
| 53 | 53 | $this->logger->error('Token Exchange failed and responded with: error', ['full output' => $output]); |
| 54 | 54 | return false; |
| 55 | 55 | } |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | * the Tiqr_DeviceStorage factory will call this for you. |
| 59 | 59 | * @param array $options The options for the s |
| 60 | 60 | */ |
| 61 | - public function __construct($options=array(), LoggerInterface $logger) |
|
| 61 | + public function __construct($options = array(), LoggerInterface $logger) |
|
| 62 | 62 | { |
| 63 | 63 | $this->_options = $options; |
| 64 | 64 | $this->logger = $logger; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @return Tiqr_UserSecretStorage_Interface |
| 40 | 40 | */ |
| 41 | - public static function getSecretStorage($type="file", LoggerInterface $logger, $options=array()) |
|
| 41 | + public static function getSecretStorage($type = "file", LoggerInterface $logger, $options = array()) |
|
| 42 | 42 | { |
| 43 | 43 | switch ($type) { |
| 44 | 44 | case "file": |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | if (!isset($type)) { |
| 62 | 62 | throw new Exception('Class name not set'); |
| 63 | 63 | } elseif (!class_exists($type)) { |
| 64 | - throw new Exception('Class not found: ' . var_export($type, TRUE)); |
|
| 64 | + throw new Exception('Class not found: '.var_export($type, TRUE)); |
|
| 65 | 65 | } |
| 66 | 66 | $instance = new $type($options, $logger); |
| 67 | 67 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @throws Exception |
| 46 | 46 | */ |
| 47 | - public static function getStorage($type="file", $options=array(), $secretoptions=array(), LoggerInterface $logger) |
|
| 47 | + public static function getStorage($type = "file", $options = array(), $secretoptions = array(), LoggerInterface $logger) |
|
| 48 | 48 | { |
| 49 | 49 | switch ($type) { |
| 50 | 50 | case "file": |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | if (!isset($type)) { |
| 64 | 64 | throw new Exception('Class name not set'); |
| 65 | 65 | } elseif (!class_exists($type)) { |
| 66 | - throw new Exception('Class not found: ' . var_export($type, TRUE)); |
|
| 66 | + throw new Exception('Class not found: '.var_export($type, TRUE)); |
|
| 67 | 67 | } |
| 68 | 68 | $instance = new $type($options, $secretoptions); |
| 69 | 69 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @return Tiqr_OcraService_Interface |
| 40 | 40 | */ |
| 41 | - public static function getOcraService($type="tiqr", $options=array(), LoggerInterface $logger) |
|
| 41 | + public static function getOcraService($type = "tiqr", $options = array(), LoggerInterface $logger) |
|
| 42 | 42 | { |
| 43 | 43 | switch ($type) { |
| 44 | 44 | case "tiqr": |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | if (!isset($type)) { |
| 54 | 54 | throw new Exception('Class name not set'); |
| 55 | 55 | } elseif (!class_exists($type)) { |
| 56 | - throw new Exception('Class not found: ' . var_export($type, TRUE)); |
|
| 56 | + throw new Exception('Class not found: '.var_export($type, TRUE)); |
|
| 57 | 57 | } |
| 58 | 58 | $instance = new $type($options); |
| 59 | 59 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * The default configuration |
| 52 | 52 | */ |
| 53 | 53 | const DEFAULT_HOST = '127.0.0.1'; |
| 54 | - const DEFAULT_PORT = 11211; |
|
| 54 | + const DEFAULT_PORT = 11211; |
|
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * Get the prefix to use for all keys in memcache. |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * (non-PHPdoc) |
| 103 | 103 | * @see library/tiqr/Tiqr/StateStorage/Tiqr_StateStorage_Abstract::setValue() |
| 104 | 104 | */ |
| 105 | - public function setValue($key, $value, $expire=0) |
|
| 105 | + public function setValue($key, $value, $expire = 0) |
|
| 106 | 106 | { |
| 107 | 107 | $key = $this->_getKeyPrefix().$key; |
| 108 | 108 | |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | public function setValue($key, $value, $expire=0) |
| 40 | 40 | { |
| 41 | 41 | $envelope = array("expire"=>$expire, |
| 42 | - "createdAt"=>time(), |
|
| 43 | - "value"=>$value); |
|
| 42 | + "createdAt"=>time(), |
|
| 43 | + "value"=>$value); |
|
| 44 | 44 | $filename = $this->_stateFilename($key); |
| 45 | 45 | |
| 46 | 46 | file_put_contents($filename, serialize($envelope)); |
@@ -72,12 +72,12 @@ discard block |
||
| 72 | 72 | if (file_exists($filename)) { |
| 73 | 73 | $envelope = unserialize(file_get_contents($filename)); |
| 74 | 74 | if ($envelope["expire"]!=0) { |
| 75 | - // This data is time-limited. If it's too old we discard it. |
|
| 76 | - if (time()-$envelope["createdAt"] > $envelope["expire"]) { |
|
| 77 | - $this->unsetValue($key); |
|
| 78 | - $this->logger->error('Unable to retrieve the state storage value, it is expired'); |
|
| 79 | - return NULL; |
|
| 80 | - } |
|
| 75 | + // This data is time-limited. If it's too old we discard it. |
|
| 76 | + if (time()-$envelope["createdAt"] > $envelope["expire"]) { |
|
| 77 | + $this->unsetValue($key); |
|
| 78 | + $this->logger->error('Unable to retrieve the state storage value, it is expired'); |
|
| 79 | + return NULL; |
|
| 80 | + } |
|
| 81 | 81 | } |
| 82 | 82 | return $envelope["value"]; |
| 83 | 83 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * (non-PHPdoc) |
| 37 | 37 | * @see library/tiqr/Tiqr/StateStorage/Tiqr_StateStorage_Abstract::setValue() |
| 38 | 38 | */ |
| 39 | - public function setValue($key, $value, $expire=0) |
|
| 39 | + public function setValue($key, $value, $expire = 0) |
|
| 40 | 40 | { |
| 41 | 41 | $envelope = array("expire"=>$expire, |
| 42 | 42 | "createdAt"=>time(), |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | $filename = $this->_stateFilename($key); |
| 72 | 72 | if (file_exists($filename)) { |
| 73 | 73 | $envelope = unserialize(file_get_contents($filename)); |
| 74 | - if ($envelope["expire"]!=0) { |
|
| 74 | + if ($envelope["expire"] != 0) { |
|
| 75 | 75 | // This data is time-limited. If it's too old we discard it. |
| 76 | - if (time()-$envelope["createdAt"] > $envelope["expire"]) { |
|
| 76 | + if (time() - $envelope["createdAt"] > $envelope["expire"]) { |
|
| 77 | 77 | $this->unsetValue($key); |
| 78 | 78 | $this->logger->error('Unable to retrieve the state storage value, it is expired'); |
| 79 | 79 | return NULL; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | private function cleanExpired() { |
| 73 | 73 | $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `expire` < ? AND NOT `expire` = 0"); |
| 74 | - if (!$sth->execute(array(time()))){ |
|
| 74 | + if (!$sth->execute(array(time()))) { |
|
| 75 | 75 | $this->logger->error('Unable to remove expired keys from the pdo state storage'); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | * (non-PHPdoc) |
| 81 | 81 | * @see library/tiqr/Tiqr/StateStorage/Tiqr_StateStorage_Abstract::setValue() |
| 82 | 82 | */ |
| 83 | - public function setValue($key, $value, $expire=0) |
|
| 83 | + public function setValue($key, $value, $expire = 0) |
|
| 84 | 84 | { |
| 85 | - if (((float) rand() /(float) getrandmax()) < $this->cleanupProbability) { |
|
| 85 | + if (((float) rand() / (float) getrandmax()) < $this->cleanupProbability) { |
|
| 86 | 86 | $this->cleanExpired(); |
| 87 | 87 | } |
| 88 | 88 | if ($this->keyExists($key)) { |
@@ -92,9 +92,9 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | // $expire == 0 means never expire |
| 94 | 94 | if ($expire != 0) { |
| 95 | - $expire+=time(); // Store unix timestamp after which the expires |
|
| 95 | + $expire += time(); // Store unix timestamp after which the expires |
|
| 96 | 96 | } |
| 97 | - $sth->execute(array(serialize($value),$expire,$key)); |
|
| 97 | + $sth->execute(array(serialize($value), $expire, $key)); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $this->logger->error('Unable to prepare the get key statement'); |
| 122 | 122 | return NULL; |
| 123 | 123 | } |
| 124 | - if (false === $sth->execute(array($key, time())) ) { |
|
| 124 | + if (false === $sth->execute(array($key, time()))) { |
|
| 125 | 125 | $this->logger->error('Unable to get key from the pdo state storage'); |
| 126 | 126 | return NULL; |
| 127 | 127 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param mixed $value The data to store in state storage |
| 48 | 48 | * @param int $expire The expiration (in seconds) of the data |
| 49 | 49 | */ |
| 50 | - public abstract function setValue($key, $value, $expire=0); |
|
| 50 | + public abstract function setValue($key, $value, $expire = 0); |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Remove a value from the state storage |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * a state storage instance of a certain type. |
| 82 | 82 | * @param array $options An array of options for the state storage |
| 83 | 83 | */ |
| 84 | - public function __construct($options=array(), LoggerInterface $logger) |
|
| 84 | + public function __construct($options = array(), LoggerInterface $logger) |
|
| 85 | 85 | { |
| 86 | 86 | $this->logger = $logger; |
| 87 | 87 | $this->_options = $options; |