<?php

namespace Plummer\Calendar;

abstract class CalendarAbstract implements CalendarInterface
{
	protected $events;

	protected $recurrenceTypes;

	protected function __construct(\Iterator $events, $recurrenceTypes)
	{
		$this->events = $events;
		$this->addRecurrenceTypes($recurrenceTypes);
	}

	public static function make(\Iterator $events, $recurrenceTypes = [])
	{
		return new static($events, $recurrenceTypes);
	}

	public function addEvents(array $events)
	{
		foreach($events as $event) {
			$this->addEvent($event);
		}
	}

	public function addRecurrenceTypes(array $recurrenceTypes)
	{
		foreach($recurrenceTypes as $recurrenceType) {
			$this->addRecurrenceType($recurrenceType);
		}
	}

	abstract public function addEvent(EventInterface $event);

	abstract public function addRecurrenceType(RecurrenceInterface $recurrenceType);

	abstract public function getEvents();
}

<?php

namespace Plummer\Calendar;

abstract class CalendarAbstract implements CalendarInterface
{
	protected $name;

	protected $events;

	protected $recurrenceTypes;

	public function __construct($name)
	{
		$this->name = $name;
	}

	public function addEvents($events)
	{
		if($events instanceof \Iterator) {
			$this->events->append($events);
		}
		elseif(is_array($events)) {
			foreach($events as $key => $event) {
				$this->events[$key] = $event;
			}
		}
	}

	public function addRecurrenceTypes($recurrenceTypes)
	{
		if($recurrenceTypes instanceof \Iterator) {
			$this->recurrenceTypes->append($recurrenceTypes);
		}
		elseif(is_array($recurrenceTypes)) {
			foreach($recurrenceTypes as $key => $recurrenceType) {
				$this->recurrenceTypes[$key] = $recurrenceType;
			}
		}
	}

	abstract public function addEvent(EventInterface $event);

	abstract public function addRecurrenceType(RecurrenceInterface $recurrenceType);

	abstract public function getEvents();
}

Restructure abstract calendar to use iterators.
Restructure abstract calendar to use iterators.
