Browse Source

Added __invoke() to SignalTrap and fixed phpunit xml

master 0.1.5
Noccy 2 years ago
parent
commit
c855f92ecd
  1. 11
      examples/signaltraps.php
  2. 2
      phpunit.xml
  3. 7
      src/Signal/SignalTrap.php

11
examples/signaltraps.php

@ -9,8 +9,15 @@ use NoccyLabs\Ipc\Signal\SignalTrap;
$trap = new SignalTrap(SIGINT);
echo "Press ctrl-c...\n";
while (!$trap->isTrapped()) {
while (!$trap->isTrapped(true)) {
usleep(10000);
}
echo "Thanks!\n";
echo "Thanks!\n";
echo "And once more...\n";
while (!$trap(true)) {
usleep(10000);
}
echo "Thanks!\n";

2
phpunit.xml

@ -8,7 +8,7 @@
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuite>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
</testsuite>

7
src/Signal/SignalTrap.php

@ -45,4 +45,9 @@ class SignalTrap
return false;
}
}
public function __invoke($reset=true):bool
{
return $this->isTrapped($reset);
}
}

Loading…
Cancel
Save