Refactor method to throw exception instead of true/false
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
parent
fbe62e1985
commit
14d802b8f3
|
@ -129,15 +129,19 @@ class Base extends Command implements CompletionAwareInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* Throw InterruptedException when interrupted by user
|
||||||
|
*
|
||||||
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
protected function hasBeenInterrupted() {
|
protected function hasBeenInterrupted() {
|
||||||
// return always false if pcntl_signal functions are not accessible
|
if ($this->php_pcntl_signal === false) {
|
||||||
if ($this->php_pcntl_signal) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pcntl_signal_dispatch();
|
pcntl_signal_dispatch();
|
||||||
return $this->interrupted;
|
|
||||||
} else {
|
if ($this->interrupted === true) {
|
||||||
return false;
|
throw new InterruptedException('Command interrupted by user');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue