diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2018-10-07 18:12:38 +0200 |
---|---|---|
committer | Daniel Kesselberg <mail@danielkesselberg.de> | 2018-10-07 18:12:38 +0200 |
commit | 14d802b8f36ed8dbf1621050bc704cfac821339f (patch) | |
tree | 5617905ddbb6f27c852eee91f657a6d247f41e76 /core | |
parent | fbe62e198594fcb130884e7e98f669ff4516b90b (diff) | |
download | nextcloud-server-14d802b8f36ed8dbf1621050bc704cfac821339f.tar.gz nextcloud-server-14d802b8f36ed8dbf1621050bc704cfac821339f.zip |
Refactor method to throw exception instead of true/false
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'core')
-rw-r--r-- | core/Command/Base.php | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/core/Command/Base.php b/core/Command/Base.php index dbf6c71b8f4..0695582ef50 100644 --- a/core/Command/Base.php +++ b/core/Command/Base.php @@ -129,15 +129,19 @@ class Base extends Command implements CompletionAwareInterface { } /** - * @return bool + * Throw InterruptedException when interrupted by user + * + * @throws InterruptedException */ protected function hasBeenInterrupted() { - // return always false if pcntl_signal functions are not accessible - if ($this->php_pcntl_signal) { - pcntl_signal_dispatch(); - return $this->interrupted; - } else { - return false; + if ($this->php_pcntl_signal === false) { + return; + } + + pcntl_signal_dispatch(); + + if ($this->interrupted === true) { + throw new InterruptedException('Command interrupted by user'); } } |