Passed
Pull Request — develop (#27)
by Michiel
06:19
created
library/tiqr/Tiqr/DeviceStorage/TokenExchange.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,15 +41,15 @@
 block discarded – undo
41 41
     {
42 42
         $url = $this->_options["url"]."?appId=".$this->_options["appid"];
43 43
         
44
-        $url.= "&notificationToken=".$notificationToken;
44
+        $url .= "&notificationToken=".$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
         }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/DeviceStorage/Abstract.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserSecretStorage.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserStorage.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OcraService.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/StateStorage/Memcache.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
library/tiqr/Tiqr/StateStorage/File.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
library/tiqr/Tiqr/StateStorage/Pdo.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/StateStorage/Abstract.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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;        
Please login to merge, or discard this patch.