summaryrefslogtreecommitdiff
path: root/app/EventBuilder/EventIteratorBuilder.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-07-23 14:50:59 -0400
committerFrederic Guillot <fred@kanboard.net>2016-07-23 14:50:59 -0400
commita823cc1d08535539f850711c0b9edb5b648f1960 (patch)
tree0988d0fd6dba3fe304efcf3fadc0b6f0f715fa67 /app/EventBuilder/EventIteratorBuilder.php
parentb6119e7dee84869a619dedccd9c80df4422a4f5b (diff)
NotificationModel refactoring
Diffstat (limited to 'app/EventBuilder/EventIteratorBuilder.php')
-rw-r--r--app/EventBuilder/EventIteratorBuilder.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/app/EventBuilder/EventIteratorBuilder.php b/app/EventBuilder/EventIteratorBuilder.php
new file mode 100644
index 00000000..afa146b6
--- /dev/null
+++ b/app/EventBuilder/EventIteratorBuilder.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace Kanboard\EventBuilder;
+
+use Iterator;
+
+/**
+ * Class EventIteratorBuilder
+ *
+ * @package Kanboard\EventBuilder
+ * @author Frederic Guillot
+ */
+class EventIteratorBuilder implements Iterator {
+ private $position = 0;
+ private $builders = array();
+
+ /**
+ * @return $this
+ */
+ public function withBuilder(BaseEventBuilder $builder)
+ {
+ $this->builders[] = $builder;
+ return $this;
+ }
+
+ public function rewind() {
+ $this->position = 0;
+ }
+
+ /**
+ * @return BaseEventBuilder
+ */
+ public function current() {
+ return $this->builders[$this->position];
+ }
+
+ public function key() {
+ return $this->position;
+ }
+
+ public function next() {
+ ++$this->position;
+ }
+
+ public function valid() {
+ return isset($this->builders[$this->position]);
+ }
+}