aboutsummaryrefslogtreecommitdiff
path: root/src/callnotifier/Source/File.php
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2012-07-14 22:28:47 +0200
committerChristian Weiske <cweiske@cweiske.de>2012-07-14 22:28:47 +0200
commit706ce1501a9ab1a33e4106774665c631a3ad3749 (patch)
tree3193e52b2388831012806db6ad331afe73db173c /src/callnotifier/Source/File.php
parent19e5e158f8a6e9dda406c2eb70ad035211613df8 (diff)
downloadauerswald-callnotifier-706ce1501a9ab1a33e4106774665c631a3ad3749.tar.gz
auerswald-callnotifier-706ce1501a9ab1a33e4106774665c631a3ad3749.zip
dumping network data is possible now
Diffstat (limited to 'src/callnotifier/Source/File.php')
-rw-r--r--src/callnotifier/Source/File.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/callnotifier/Source/File.php b/src/callnotifier/Source/File.php
new file mode 100644
index 0000000..c358397
--- /dev/null
+++ b/src/callnotifier/Source/File.php
@@ -0,0 +1,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);
+ }
+}
+
+?>