blob: 9b6a03ea07069d28ab4906301abc11a71caeb7a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<?php
namespace callnotifier;
class Source_File
{
public function __construct($config, $handler)
{
$this->config = $config;
$this->handler = $handler;
}
public function run()
{
$file = $this->config->replayFile;
if (!file_exists($file)) {
throw new \Exception('Replay file does not exist');
}
$handle = fopen($file, 'r');
if (!$handle) {
throw new \Exception('Cannot open replay file for reading');
}
while (($line = fgets($handle, 4096)) !== false) {
$this->handler->handle($line);
}
if (!feof($handle)) {
throw new \Exception('unexpected fgets() fail');
}
fclose($handle);
}
}
?>
|