| 1 | <?php |
||
| 17 | class RuntimeLock implements LockInterface |
||
| 18 | { |
||
| 19 | /** @var string */ |
||
| 20 | private $name; |
||
| 21 | |||
| 22 | /** @var boolean */ |
||
| 23 | private $isLocked; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param string $name |
||
| 27 | * @throws InvalidArgumentException |
||
| 28 | */ |
||
| 29 | public function __construct($name = '') |
||
| 30 | { |
||
| 31 | if (strlen($name) > 0) { |
||
| 32 | $this->setResource($name); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @return bool |
||
| 38 | */ |
||
| 39 | public function isLocked() |
||
| 43 | |||
| 44 | |||
| 45 | |||
| 46 | /** |
||
| 47 | * @throws \RuntimeException |
||
| 48 | */ |
||
| 49 | public function acquire() |
||
| 59 | |||
| 60 | |||
| 61 | |||
| 62 | /** |
||
| 63 | * @throws \RuntimeException |
||
| 64 | */ |
||
| 65 | public function release() |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @return mixed|string |
||
| 78 | */ |
||
| 79 | public function getResource() |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @param mixed|string $resource |
||
| 86 | * @throws InvalidArgumentException |
||
| 87 | */ |
||
| 88 | public function setResource($resource) |
||
| 92 | } |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.