1 | <?php |
||
8 | class CommandExecutionLock implements ICommandExecutionLock { |
||
9 | /** |
||
10 | * @var array |
||
11 | */ |
||
12 | protected $locks = []; |
||
13 | |||
14 | /** |
||
15 | * CommandExecutionLock constructor. |
||
16 | */ |
||
17 | public function __construct() { |
||
20 | |||
21 | /** |
||
22 | * @param ICommand $command |
||
23 | * @param bool $allowParallelism |
||
24 | * |
||
25 | * @return string |
||
26 | */ |
||
27 | public function lockCommand(ICommand $command, $allowParallelism = true) { |
||
44 | |||
45 | /** |
||
46 | * @param ICommand $command |
||
47 | */ |
||
48 | public function unlockCommand(ICommand $command) { |
||
51 | |||
52 | /** |
||
53 | * Delete all locks created by this particular instance. |
||
54 | */ |
||
55 | public function unlockAllCommands() { |
||
58 | |||
59 | /** |
||
60 | * Handle shutdown events and clean up lock files. |
||
61 | */ |
||
62 | protected function handleShutdowns() { |
||
88 | |||
89 | /** |
||
90 | * @return string |
||
91 | */ |
||
92 | protected function getLockFileBaseName() { |
||
95 | |||
96 | /** |
||
97 | * @param string $value |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | protected function getLockName($value) { |
||
104 | |||
105 | /** |
||
106 | * @param string $value |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | protected function createLock($value) { |
||
117 | |||
118 | /** |
||
119 | * @param string $value |
||
120 | */ |
||
121 | protected function deleteLock($value) { |
||
125 | |||
126 | /** |
||
127 | * Remove all locks for commands called trough |
||
128 | * this particular lock instance. |
||
129 | */ |
||
130 | protected function deleteAllLocks() { |
||
135 | |||
136 | /** |
||
137 | * @param string $value |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | protected function isLocked($value) { |
||
144 | } |
||
145 |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.