@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | - * @return mixed |
|
| 77 | + * @return string |
|
| 78 | 78 | */ |
| 79 | 79 | public function getResource() |
| 80 | 80 | { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | - * @param mixed $resource |
|
| 85 | + * @param string $resource |
|
| 86 | 86 | * @throws InvalidArgumentException |
| 87 | 87 | */ |
| 88 | 88 | public function setResource($resource) |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function acquire() |
| 50 | 50 | { |
| 51 | - if ($this->isLocked()) { |
|
| 52 | - throw new RuntimeException( |
|
| 51 | + if ($this->isLocked()) { |
|
| 52 | + throw new RuntimeException( |
|
| 53 | 53 | 'Can not acquire lock, lock already exists.' |
| 54 | 54 | ); |
| 55 | - } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | $this->isLocked = true; |
| 58 | 58 | } |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function release() |
| 66 | 66 | { |
| 67 | - if (!$this->isLocked()) { |
|
| 68 | - throw new RuntimeException( |
|
| 67 | + if (!$this->isLocked()) { |
|
| 68 | + throw new RuntimeException( |
|
| 69 | 69 | 'Can not release lock, no lock exists.' |
| 70 | 70 | ); |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | $this->isLocked = false; |
| 74 | 74 | } |
@@ -15,20 +15,20 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | interface LockInterface |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @return boolean |
|
| 20 | - */ |
|
| 21 | - public function isLocked(); |
|
| 18 | + /** |
|
| 19 | + * @return boolean |
|
| 20 | + */ |
|
| 21 | + public function isLocked(); |
|
| 22 | 22 | |
| 23 | - /** |
|
| 23 | + /** |
|
| 24 | 24 | * @throws \RuntimeException |
| 25 | - */ |
|
| 26 | - public function acquire(); |
|
| 25 | + */ |
|
| 26 | + public function acquire(); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 28 | + /** |
|
| 29 | 29 | * @throws \RuntimeException |
| 30 | - */ |
|
| 31 | - public function release(); |
|
| 30 | + */ |
|
| 31 | + public function release(); |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * @return mixed |
@@ -34,37 +34,37 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @throws \RuntimeException |
| 36 | 36 | */ |
| 37 | - public function acquire() |
|
| 38 | - { |
|
| 39 | - if ($this->isLocked()) { |
|
| 40 | - throw new RuntimeException( |
|
| 37 | + public function acquire() |
|
| 38 | + { |
|
| 39 | + if ($this->isLocked()) { |
|
| 40 | + throw new RuntimeException( |
|
| 41 | 41 | 'Can not acquire lock, lock already exists.' |
| 42 | 42 | ); |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | file_put_contents($this->getResource(), 'process id: ' . getmypid()); |
| 46 | - } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * @throws \RuntimeException |
| 50 | 50 | */ |
| 51 | - public function release() |
|
| 52 | - { |
|
| 53 | - if (!$this->isLocked()) { |
|
| 54 | - throw new RuntimeException( |
|
| 51 | + public function release() |
|
| 52 | + { |
|
| 53 | + if (!$this->isLocked()) { |
|
| 54 | + throw new RuntimeException( |
|
| 55 | 55 | 'Can not release lock, no lock exists.' |
| 56 | 56 | ); |
| 57 | - } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | unlink($this->getResource()); |
| 60 | - } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 62 | + /** |
|
| 63 | 63 | * @return bool |
| 64 | - */ |
|
| 65 | - public function isLocked() |
|
| 66 | - { |
|
| 67 | - return file_exists($this->getResource()); |
|
| 64 | + */ |
|
| 65 | + public function isLocked() |
|
| 66 | + { |
|
| 67 | + return file_exists($this->getResource()); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -108,19 +108,19 @@ discard block |
||
| 108 | 108 | return ($stringEnding == $endsWith); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * @return boolean |
|
| 113 | - */ |
|
| 114 | - private function isValidName() |
|
| 115 | - { |
|
| 116 | - return (is_string($this->name) && strlen($this->name) > 0); |
|
| 117 | - } |
|
| 111 | + /** |
|
| 112 | + * @return boolean |
|
| 113 | + */ |
|
| 114 | + private function isValidName() |
|
| 115 | + { |
|
| 116 | + return (is_string($this->name) && strlen($this->name) > 0); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * @return string |
|
| 121 | - */ |
|
| 122 | - private function getDefaultName() |
|
| 123 | - { |
|
| 124 | - return (string) str_replace('\\', '_', get_class($this)) . '.lock'; |
|
| 125 | - } |
|
| 119 | + /** |
|
| 120 | + * @return string |
|
| 121 | + */ |
|
| 122 | + private function getDefaultName() |
|
| 123 | + { |
|
| 124 | + return (string) str_replace('\\', '_', get_class($this)) . '.lock'; |
|
| 125 | + } |
|
| 126 | 126 | } |
| 127 | 127 | \ No newline at end of file |