@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $key = $lock->key(); |
| 46 | 46 | $fileName = $this->getLockPath($key); |
| 47 | 47 | |
| 48 | - if(file_exists($fileName)){ |
|
| 48 | + if (file_exists($fileName)) { |
|
| 49 | 49 | throw new ExistingKeyException(sprintf('The key "%s" already exists.', $key)); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | private function save(Lock $lock, $fileName) |
| 61 | 61 | { |
| 62 | - $file = @fopen($fileName,'w'); |
|
| 62 | + $file = @fopen($fileName, 'w'); |
|
| 63 | 63 | |
| 64 | - if (flock($file,LOCK_EX)) { |
|
| 64 | + if (flock($file, LOCK_EX)) { |
|
| 65 | 65 | fwrite($file, serialize($lock)); |
| 66 | - flock($file,LOCK_UN); |
|
| 66 | + flock($file, LOCK_UN); |
|
| 67 | 67 | } else { |
| 68 | 68 | throw new LockingKeyException(sprintf('Error locking file "%s".', $lock->key())); |
| 69 | 69 | } |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | $files = scandir($this->lockPath); |
| 80 | 80 | |
| 81 | - foreach($files as $file){ |
|
| 82 | - if(is_file($this->lockPath.$file)) { |
|
| 81 | + foreach ($files as $file) { |
|
| 82 | + if (is_file($this->lockPath.$file)) { |
|
| 83 | 83 | unlink($this->lockPath.$file); |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function delete($key) |
| 93 | 93 | { |
| 94 | - if(!$this->exists($key)){ |
|
| 94 | + if (!$this->exists($key)) { |
|
| 95 | 95 | throw new NotExistingKeyException(sprintf('The key "%s" does not exists.', $key)); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function exists($key) |
| 106 | 106 | { |
| 107 | - if(!@fopen($this->getLockPath($key),'r')){ |
|
| 107 | + if (!@fopen($this->getLockPath($key), 'r')) { |
|
| 108 | 108 | return false; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function get($key) |
| 129 | 129 | { |
| 130 | - if(!$this->exists($key)){ |
|
| 130 | + if (!$this->exists($key)) { |
|
| 131 | 131 | throw new NotExistingKeyException(sprintf('The key "%s" does not exists.', $key)); |
| 132 | 132 | } |
| 133 | 133 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | unset($files[0]); |
| 146 | 146 | unset($files[1]); |
| 147 | 147 | |
| 148 | - foreach ($files as $lock){ |
|
| 148 | + foreach ($files as $lock) { |
|
| 149 | 149 | $locks[] = str_replace('.lock', '', $lock); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | $fileName = $this->getLockPath($key); |
| 164 | 164 | |
| 165 | - if(!file_exists($fileName)){ |
|
| 165 | + if (!file_exists($fileName)) { |
|
| 166 | 166 | throw new NotExistingKeyException(sprintf('The key "%s" does not exists.', $key)); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $key = $lock->key(); |
| 35 | 35 | |
| 36 | - if($this->redis->hget(self::LOCK_LIST_NAME, $key)){ |
|
| 36 | + if ($this->redis->hget(self::LOCK_LIST_NAME, $key)) { |
|
| 37 | 37 | throw new ExistingKeyException(sprintf('The key "%s" already exists.', $key)); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function delete($key) |
| 72 | 72 | { |
| 73 | - if(!$this->exists($key)){ |
|
| 73 | + if (!$this->exists($key)) { |
|
| 74 | 74 | throw new NotExistingKeyException(sprintf('The key "%s" does not exists.', $key)); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function get($key) |
| 95 | 95 | { |
| 96 | - if(!$this->exists($key)){ |
|
| 96 | + if (!$this->exists($key)) { |
|
| 97 | 97 | throw new NotExistingKeyException(sprintf('The key "%s" does not exists.', $key)); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function update($key, $payload) |
| 117 | 117 | { |
| 118 | - if(!$this->redis->hget(self::LOCK_LIST_NAME, $key)){ |
|
| 118 | + if (!$this->redis->hget(self::LOCK_LIST_NAME, $key)) { |
|
| 119 | 119 | throw new NotExistingKeyException(sprintf('The key "%s" does not exists.', $key)); |
| 120 | 120 | } |
| 121 | 121 | |