@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @throws Exception |
44 | 44 | */ |
45 | - public static function getStorage($type="file", $options=array(), $secretoptions=array()) |
|
45 | + public static function getStorage($type = "file", $options = array(), $secretoptions = array()) |
|
46 | 46 | { |
47 | 47 | switch ($type) { |
48 | 48 | 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, $secretoptions); |
67 | 67 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function setBaseURL($apiBaseURL) |
27 | 27 | { |
28 | - $this->_apiBaseURL = rtrim($apiBaseURL, '/') . '/'; |
|
28 | + $this->_apiBaseURL = rtrim($apiBaseURL, '/').'/'; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | protected function callAPI($resource, $method = "GET", $data = array(), $headers = array()) |
79 | 79 | { |
80 | 80 | $ch = curl_init(); |
81 | - curl_setopt($ch, CURLOPT_URL, $this->_apiBaseURL . ltrim($resource, '/')); |
|
81 | + curl_setopt($ch, CURLOPT_URL, $this->_apiBaseURL.ltrim($resource, '/')); |
|
82 | 82 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
83 | 83 | |
84 | 84 | // Explicitly empty null values, because http_build_query will throw away |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | $headerArray = array(); |
109 | 109 | foreach ($headers as $key => $value) { |
110 | - $headerArray[] = $key . ': ' . $value; |
|
110 | + $headerArray[] = $key.': '.$value; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param mixed $value The data to store in state storage |
42 | 42 | * @param int $expire The expiration (in seconds) of the data |
43 | 43 | */ |
44 | - public abstract function setValue($key, $value, $expire=0); |
|
44 | + public abstract function setValue($key, $value, $expire = 0); |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Remove a value from the state storage |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * a state storage instance of a certain type. |
76 | 76 | * @param array $options An array of options for the state storage |
77 | 77 | */ |
78 | - public function __construct($options=array()) |
|
78 | + public function __construct($options = array()) |
|
79 | 79 | { |
80 | 80 | $this->_options = $options; |
81 | 81 | } |
@@ -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. |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * (non-PHPdoc) |
100 | 100 | * @see library/tiqr/Tiqr/StateStorage/Tiqr_StateStorage_Abstract::setValue() |
101 | 101 | */ |
102 | - public function setValue($key, $value, $expire=0) |
|
102 | + public function setValue($key, $value, $expire = 0) |
|
103 | 103 | { |
104 | 104 | $key = $this->_getKeyPrefix().$key; |
105 | 105 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $key = $this->_getKeyPrefix().$key; |
131 | 131 | |
132 | 132 | $result = $this->_memcache->get($key); |
133 | - if( $result === false ) |
|
133 | + if ($result === false) |
|
134 | 134 | return null; |
135 | 135 | return $result; |
136 | 136 | } |
@@ -130,8 +130,9 @@ |
||
130 | 130 | $key = $this->_getKeyPrefix().$key; |
131 | 131 | |
132 | 132 | $result = $this->_memcache->get($key); |
133 | - if( $result === false ) |
|
134 | - return null; |
|
133 | + if( $result === false ) { |
|
134 | + return null; |
|
135 | + } |
|
135 | 136 | return $result; |
136 | 137 | } |
137 | 138 |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | * (non-PHPdoc) |
46 | 46 | * @see library/tiqr/Tiqr/StateStorage/Tiqr_StateStorage_Abstract::setValue() |
47 | 47 | */ |
48 | - public function setValue($key, $value, $expire=0) |
|
48 | + public function setValue($key, $value, $expire = 0) |
|
49 | 49 | { |
50 | 50 | if ($this->keyExists($key)) { |
51 | 51 | $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET `value` = ?, `expire` = ? WHERE `key` = ?"); |
52 | 52 | } else { |
53 | 53 | $sth = $this->handle->prepare("INSERT INTO ".$this->tablename." (`value`,`expire`,`key`) VALUES (?,?,?)"); |
54 | 54 | } |
55 | - $sth->execute(array(serialize($value),time()+$expire,$key)); |
|
55 | + $sth->execute(array(serialize($value), time() + $expire, $key)); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | return NULL; |
84 | 84 | } |
85 | 85 | |
86 | - public function __construct($config=array()) |
|
86 | + public function __construct($config = array()) |
|
87 | 87 | { |
88 | 88 | $this->tablename = $config['table']; |
89 | - $this->handle = new PDO($config['dsn'],$config['username'],$config['password']); |
|
89 | + $this->handle = new PDO($config['dsn'], $config['username'], $config['password']); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | } |
@@ -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)); |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | if (file_exists($filename)) { |
71 | 71 | $envelope = unserialize(file_get_contents($filename)); |
72 | 72 | if ($envelope["expire"]!=0) { |
73 | - // This data is time-limited. If it's too old we discard it. |
|
74 | - if (time()-$envelope["createdAt"] > $envelope["expire"]) { |
|
75 | - $this->unsetValue($key); |
|
76 | - return NULL; |
|
77 | - } |
|
73 | + // This data is time-limited. If it's too old we discard it. |
|
74 | + if (time()-$envelope["createdAt"] > $envelope["expire"]) { |
|
75 | + $this->unsetValue($key); |
|
76 | + return NULL; |
|
77 | + } |
|
78 | 78 | } |
79 | 79 | return $envelope["value"]; |
80 | 80 | } |
@@ -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(), |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | $filename = $this->_stateFilename($key); |
70 | 70 | if (file_exists($filename)) { |
71 | 71 | $envelope = unserialize(file_get_contents($filename)); |
72 | - if ($envelope["expire"]!=0) { |
|
72 | + if ($envelope["expire"] != 0) { |
|
73 | 73 | // This data is time-limited. If it's too old we discard it. |
74 | - if (time()-$envelope["createdAt"] > $envelope["expire"]) { |
|
74 | + if (time() - $envelope["createdAt"] > $envelope["expire"]) { |
|
75 | 75 | $this->unsetValue($key); |
76 | 76 | return NULL; |
77 | 77 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public static function randomBytes($length) |
40 | 40 | { |
41 | - if(function_exists('openssl_random_pseudo_bytes')) { |
|
41 | + if(function_exists('openssl_random_pseudo_bytes')) { |
|
42 | 42 | $rnd = openssl_random_pseudo_bytes($length, $strong); |
43 | 43 | if($strong === TRUE && $rnd !== FALSE) { |
44 | 44 | return $rnd; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public static function randomHexString($length) |
67 | 67 | { |
68 | - $result = bin2hex(self::randomBytes($length)); |
|
69 | - return $result; |
|
68 | + $result = bin2hex(self::randomBytes($length)); |
|
69 | + return $result; |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | \ No newline at end of file |
@@ -38,21 +38,21 @@ |
||
38 | 38 | */ |
39 | 39 | public static function randomBytes($length) |
40 | 40 | { |
41 | - if(function_exists('openssl_random_pseudo_bytes')) { |
|
41 | + if (function_exists('openssl_random_pseudo_bytes')) { |
|
42 | 42 | $rnd = openssl_random_pseudo_bytes($length, $strong); |
43 | - if($strong === TRUE && $rnd !== FALSE) { |
|
43 | + if ($strong === TRUE && $rnd !== FALSE) { |
|
44 | 44 | return $rnd; |
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | 48 | // When openssl_random_pseudo_bytes failed, fall back on a mt_rand based string. |
49 | 49 | |
50 | - $rnd=''; |
|
50 | + $rnd = ''; |
|
51 | 51 | |
52 | - for ($i=0;$i<$length;$i++) { |
|
53 | - $sha= sha1(mt_rand()); |
|
54 | - $char= mt_rand(0,30); |
|
55 | - $rnd.= chr(hexdec($sha[$char].$sha[$char+1])); |
|
52 | + for ($i = 0; $i < $length; $i++) { |
|
53 | + $sha = sha1(mt_rand()); |
|
54 | + $char = mt_rand(0, 30); |
|
55 | + $rnd .= chr(hexdec($sha[$char].$sha[$char + 1])); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | return $rnd; |
@@ -41,7 +41,7 @@ |
||
41 | 41 | public function encrypt($data); |
42 | 42 | |
43 | 43 | /** |
44 | - * Decrypts the given data. |
|
44 | + * Decrypts the given data. |
|
45 | 45 | * |
46 | 46 | * @param String $data Data to decrypt. |
47 | 47 | * |
@@ -57,7 +57,7 @@ |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
60 | - * Decrypts the given data. |
|
60 | + * Decrypts the given data. |
|
61 | 61 | * |
62 | 62 | * @param String $data Data to decrypt. |
63 | 63 | * |