1 | <?php |
||
17 | class NotifyHandler implements INotifyHandler { |
||
18 | /** |
||
19 | * @var Connection |
||
20 | */ |
||
21 | private $connection; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private $path; |
||
27 | |||
28 | private $listening = true; |
||
29 | |||
30 | // see error.h |
||
31 | const EXCEPTION_MAP = [ |
||
32 | ErrorCodes::RevisionMismatch => RevisionMismatchException::class, |
||
33 | ]; |
||
34 | |||
35 | /** |
||
36 | * @param Connection $connection |
||
37 | * @param string $path |
||
38 | */ |
||
39 | 15 | public function __construct(Connection $connection, $path) { |
|
43 | |||
44 | /** |
||
45 | * Get all changes detected since the start of the notify process or the last call to getChanges |
||
46 | * |
||
47 | * @return Change[] |
||
48 | */ |
||
49 | 12 | public function getChanges() { |
|
62 | |||
63 | /** |
||
64 | * Listen actively to all incoming changes |
||
65 | * |
||
66 | * Note that this is a blocking process and will cause the process to block forever if not explicitly terminated |
||
67 | * |
||
68 | * @param callable $callback |
||
69 | */ |
||
70 | 6 | public function listen($callback) { |
|
81 | |||
82 | 12 | private function parseChangeLine($line) { |
|
94 | |||
95 | 12 | private function checkForError($line) { |
|
101 | |||
102 | 15 | public function stop() { |
|
106 | |||
107 | 15 | public function __destruct() { |
|
110 | } |
||
111 |