From 9e2b2a32fd0e967ad3184e9a5d091a29953acb91 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 25 Oct 2017 16:22:10 -0700 Subject: Include composer dependencies in repo --- vendor/eluceo/ical/src/Eluceo/iCal/PropertyBag.php | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 vendor/eluceo/ical/src/Eluceo/iCal/PropertyBag.php (limited to 'vendor/eluceo/ical/src/Eluceo/iCal/PropertyBag.php') 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 @@ + + * + * 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); + } +} -- cgit v1.2.3