summaryrefslogtreecommitdiff
path: root/vendor/eluceo/ical/src/Eluceo/iCal/PropertyBag.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-10-25 16:22:10 -0700
committerFrederic Guillot <fred@kanboard.net>2017-10-25 16:22:10 -0700
commit9e2b2a32fd0e967ad3184e9a5d091a29953acb91 (patch)
tree00822e24aa1110c73ca455a8d096ef296c008cbc /vendor/eluceo/ical/src/Eluceo/iCal/PropertyBag.php
parentc507c5416251c505cb3e088a03c6664bed73c812 (diff)
Include composer dependencies in repo
Diffstat (limited to 'vendor/eluceo/ical/src/Eluceo/iCal/PropertyBag.php')
-rw-r--r--vendor/eluceo/ical/src/Eluceo/iCal/PropertyBag.php79
1 files changed, 79 insertions, 0 deletions
diff --git a/vendor/eluceo/ical/src/Eluceo/iCal/PropertyBag.php b/vendor/eluceo/ical/src/Eluceo/iCal/PropertyBag.php
new file mode 100644
index 00000000..7032360b
--- /dev/null
+++ b/vendor/eluceo/ical/src/Eluceo/iCal/PropertyBag.php
@@ -0,0 +1,79 @@
+<?php
+
+/*
+ * This file is part of the eluceo/iCal package.
+ *
+ * (c) Markus Poerschke <markus@eluceo.de>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Eluceo\iCal;
+
+class PropertyBag implements \IteratorAggregate
+{
+ /**
+ * @var array
+ */
+ protected $elements = array();
+
+ /**
+ * Creates a new Property with $name, $value and $params.
+ *
+ * @param $name
+ * @param $value
+ * @param array $params
+ *
+ * @return $this
+ */
+ public function set($name, $value, $params = array())
+ {
+ $property = new Property($name, $value, $params);
+ $this->elements[] = $property;
+
+ return $this;
+ }
+
+ /**
+ * @param string $name
+ *
+ * @return null|Property
+ */
+ public function get($name)
+ {
+ // Searching Property in elements-array
+ /** @var $property Property */
+ foreach ($this->elements as $property) {
+ if ($property->getName() == $name) {
+ return $property;
+ }
+ }
+ }
+
+ /**
+ * Adds a Property. If Property already exists an Exception will be thrown.
+ *
+ * @param Property $property
+ *
+ * @return $this
+ *
+ * @throws \Exception
+ */
+ public function add(Property $property)
+ {
+ // Property already exists?
+ if (null !== $this->get($property->getName())) {
+ throw new \Exception("Property with name '{$property->getName()}' already exists");
+ }
+
+ $this->elements[] = $property;
+
+ return $this;
+ }
+
+ public function getIterator()
+ {
+ return new \ArrayObject($this->elements);
+ }
+}