From a6ef9561af691777949e21ad0764d6899a0e61de Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 11 Feb 2016 22:29:33 +0100 Subject: [PATCH] Calendar doc comments --- Models/Calendar.php | 133 +++++++++++++++++-- Models/CalendarMapper.php | 23 ++++ Models/Event.php | 147 ++++++++++++++++++++- Models/EventMapper.php | 23 ++++ Models/EventTemplate.php | 10 +- Models/EventType.php | 6 +- Models/FrequencyInterval.php | 6 +- Models/FrequencyRelative.php | 6 +- Models/FrequencyType.php | 6 +- Models/IntervalType.php | 6 +- Models/NullEvent.php | 4 +- Models/Schedule.php | 242 ++++++++++++++++++++++++++++++++++- Models/ScheduleMapper.php | 20 ++- Models/ScheduleStatus.php | 6 +- 14 files changed, 590 insertions(+), 48 deletions(-) diff --git a/Models/Calendar.php b/Models/Calendar.php index e3840ac..ca87d3c 100644 --- a/Models/Calendar.php +++ b/Models/Calendar.php @@ -14,6 +14,7 @@ * @link http://orange-management.com */ namespace Modules\Calendar\Models; +use phpOMS\Datatypes\SmartDateTime; /** * Calendar class. @@ -69,6 +70,12 @@ class Calendar */ private $createdBy = 0; + /** + * Current date of the calendar. + * + * @var \DateTime + * @since 1.0.0 + */ private $date = null; /** @@ -79,37 +86,81 @@ class Calendar */ private $events = []; + /** + * Constructor. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function __construct() { $this->createdAt = new \DateTime('now'); - $this->date = new \DateTime('now'); + $this->date = new SmartDateTime('now'); } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getId() : int { return $this->id; } + /** + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getName() : string { return $this->name; } + /** + * @param string $name Calendar name/title + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setName(string $name) { $this->name = $name; } + /** + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getDescription() : string { return $this->description; } + /** + * @param string $desc Calendar description + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setDescription(string $desc) { $this->description = $desc; } + /** + * @param Event $event Calendar event + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function addEvent(Event $event) : int { $this->events[] = $event; @@ -121,12 +172,26 @@ class Calendar return $key; } + /** + * @return Event[] + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getEvents() : array { return $this->events; } - public function removeEvent($id) : bool + /** + * @param int $id Event id + * + * @return bool + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function removeEvent(int $id) : bool { if (isset($this->events[$id])) { unset($this->events[$id]); @@ -137,44 +202,86 @@ class Calendar return false; } - public function getEvent($id) : Event + /** + * @param int $id Event id + * + * @return Event + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getEvent(int $id) : Event { return $this->events[$id] ?? new NullEvent(); } + /** + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getCreatedAt() : \DateTime { return $this->createdAt; } + /** + * @param \DateTime $createdAt Calendar created at + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setCreatedAt(\DateTime $createdAt) { $this->createdAt = $createdAt; } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getCreatedBy() : int { return $this->createdBy; } + /** + * @param int $createdBy Creator + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setCreatedBy(int $createdBy) { $this->createdBy = $createdBy; } - public function getDate() : \DateTime { + /** + * Get current date + * + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getDate() : \DateTime + { return $this->date; } - public function setDate(\DateTime $date) { + /** + * Set current date + * + * @param \DateTime $date Current date + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setDate(\DateTime $date) + { $this->date = $date; } - - public function getDaysOfMonth() : int { - return cal_days_in_month(CAL_GREGORIAN, $this->date->format('m'), $this->date->format('Y')); - } - - public function getFirstDay() { - return getdate(mktime(null, null, null, $this->date->format('m'), 1, $this->date->format('Y')))['wday']; - } } diff --git a/Models/CalendarMapper.php b/Models/CalendarMapper.php index 1fc7b9f..21ca927 100644 --- a/Models/CalendarMapper.php +++ b/Models/CalendarMapper.php @@ -19,6 +19,17 @@ use phpOMS\DataStorage\Database\DataMapperAbstract; use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\DataStorage\Database\Query\Column; +/** + * Mapper class. + * + * @category Calendar + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ class CalendarMapper extends DataMapperAbstract { @@ -37,6 +48,12 @@ class CalendarMapper extends DataMapperAbstract 'calendar_created_at' => ['name' => 'calendar_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], ]; + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ protected static $hasMany = [ 'events' => [ 'mapper' => '\Modules\Calendar\Models\EventMapper', @@ -55,6 +72,12 @@ class CalendarMapper extends DataMapperAbstract */ protected static $table = 'calendar'; + /** + * Created at. + * + * @var string + * @since 1.0.0 + */ protected static $createdAt = 'calendar_created_at'; /** diff --git a/Models/Event.php b/Models/Event.php index d33e29b..357a277 100644 --- a/Models/Event.php +++ b/Models/Event.php @@ -20,7 +20,7 @@ use phpOMS\Account\NullAccount; use phpOMS\Datatypes\Location; /** - * Calendar class. + * Event class. * * @category Calendar * @package Framework @@ -73,18 +73,38 @@ class Event */ private $createdBy = 0; + /** + * Event type. + * + * Single event or a template (templates have a repeating) + * + * @var int + * @since 1.0.0 + */ private $type = EventType::SINGLE; + /** + * Schedule + * + * @var Schedule + * @since 1.0.0 + */ private $schedule = null; /** - * People. + * Location of the event. * * @var array * @since 1.0.0 */ private $location = null; + /** + * Calendar + * + * @var int + * @since 1.0.0 + */ private $calendar = 0; /** @@ -95,33 +115,73 @@ class Event */ private $people = []; + /** + * Constructor. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function __construct() { $this->createdAt = new \DateTime('now'); $this->location = new Location(); - $this->schedule = new Schedule(); + $this->schedule = new Schedule(); } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getId() : int { return $this->id; } + /** + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getName() : string { return $this->name; } + /** + * @return Account[] + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getPeople() : array { return $this->people; } + /** + * @param int $id Account id + * + * @return Account + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getPerson(int $id) : Account { return $this->people[$id] ?? new NullAccount(); } + /** + * @param Account $person Person to add + * + * @return int Account id/position + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function addPerson(Account $person) { $this->people[] = $person; @@ -154,67 +214,146 @@ class Event return false; } + /** + * @param string $name Event name/title + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setName(string $name) { $this->name = $name; } + /** + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getDescription() : string { return $this->description; } + /** + * @param string $desc Event description + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setDescription(string $desc) { $this->description = $desc; } + /** + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getCreatedAt() : \DateTime { return $this->createdAt; } + /** + * @param \DateTime $createdAt Event created at + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setCreatedAt(\DateTime $createdAt) { $this->createdAt = $createdAt; } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getCreatedBy() : int { return $this->createdBy; } + /** + * @param int $createdBy Creator + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setCreatedBy(int $createdBy) { $this->createdBy = $createdBy; } + /** + * @param Location $location Event location + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setLocation(Location $location) { $this->location = $location; } + /** + * @return Location + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getLocation() : Location { return $this->location; } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getCalendar() : int { return $this->calendar; } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getType() : int { return $this->type; } + /** + * @param int $calendar Calendar + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setCalendar(int $calendar) { $this->calendar = $calendar; } - public function getSchedule() : Schedule { + /** + * @return Schedule + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getSchedule() : Schedule + { return $this->schedule; } } diff --git a/Models/EventMapper.php b/Models/EventMapper.php index b3eb068..d8084e0 100644 --- a/Models/EventMapper.php +++ b/Models/EventMapper.php @@ -19,6 +19,17 @@ use phpOMS\DataStorage\Database\DataMapperAbstract; use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\DataStorage\Database\Query\Column; +/** + * Mapper class. + * + * @category Calendar + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ class EventMapper extends DataMapperAbstract { @@ -41,6 +52,12 @@ class EventMapper extends DataMapperAbstract 'calendar_event_created_at' => ['name' => 'calendar_event_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], ]; + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ protected static $hasOne = [ 'schedule' => [ 'mapper' => '\Modules\Calendar\Models\ScheduleMapper', @@ -56,6 +73,12 @@ class EventMapper extends DataMapperAbstract */ protected static $table = 'calendar_event'; + /** + * Created at. + * + * @var string + * @since 1.0.0 + */ protected static $createdAt = 'calendar_event_created_at'; /** diff --git a/Models/EventTemplate.php b/Models/EventTemplate.php index 27b20d0..64837f4 100644 --- a/Models/EventTemplate.php +++ b/Models/EventTemplate.php @@ -16,10 +16,10 @@ namespace Modules\Calendar\Models; /** - * Calendar class. + * Event template class. * * @category Calendar - * @package Framework + * @package Modules * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 @@ -28,5 +28,11 @@ namespace Modules\Calendar\Models; */ class EventTemplate extends Event { + /** + * Type. + * + * @var EventType + * @since 1.0.0 + */ private $type = EventType::TEMPLATE; } diff --git a/Models/EventType.php b/Models/EventType.php index 8315021..bccbf4f 100644 --- a/Models/EventType.php +++ b/Models/EventType.php @@ -18,10 +18,10 @@ namespace Modules\Calendar\Models; use phpOMS\Datatypes\Enum; /** - * Occurrence type enum. + * Event type enum. * - * @category OccurrenceType - * @package Framework + * @category Calendar + * @package Modules * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Models/FrequencyInterval.php b/Models/FrequencyInterval.php index 55564c1..8d14a5e 100644 --- a/Models/FrequencyInterval.php +++ b/Models/FrequencyInterval.php @@ -18,10 +18,10 @@ namespace Modules\Calendar\Models; use phpOMS\Datatypes\Enum; /** - * Occurrence type enum. + * Frequency interval type enum. * - * @category OccurrenceType - * @package Framework + * @category Calendar + * @package Modules * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Models/FrequencyRelative.php b/Models/FrequencyRelative.php index 5dd5718..40e590b 100644 --- a/Models/FrequencyRelative.php +++ b/Models/FrequencyRelative.php @@ -18,10 +18,10 @@ namespace Modules\Calendar\Models; use phpOMS\Datatypes\Enum; /** - * Occurrence type enum. + * Frequency relative type enum. * - * @category OccurrenceType - * @package Framework + * @category Calendar + * @package Modules * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Models/FrequencyType.php b/Models/FrequencyType.php index 95370f9..c5db122 100644 --- a/Models/FrequencyType.php +++ b/Models/FrequencyType.php @@ -18,10 +18,10 @@ namespace Modules\Calendar\Models; use phpOMS\Datatypes\Enum; /** - * Occurrence type enum. + * Frequency type enum. * - * @category OccurrenceType - * @package Framework + * @category Calendar + * @package Modules * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Models/IntervalType.php b/Models/IntervalType.php index c6c52ad..633c032 100644 --- a/Models/IntervalType.php +++ b/Models/IntervalType.php @@ -18,10 +18,10 @@ namespace Modules\Calendar\Models; use phpOMS\Datatypes\Enum; /** - * Occurrence type enum. + * Interval type type enum. * - * @category OccurrenceType - * @package Framework + * @category Calendar + * @package Modules * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Models/NullEvent.php b/Models/NullEvent.php index 1414484..1c9352e 100644 --- a/Models/NullEvent.php +++ b/Models/NullEvent.php @@ -16,10 +16,10 @@ namespace Modules\Calendar\Models; /** - * Calendar class. + * Null event class. * * @category Calendar - * @package Framework + * @package Modules * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Models/Schedule.php b/Models/Schedule.php index b7de80f..470ccfd 100644 --- a/Models/Schedule.php +++ b/Models/Schedule.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\Exception\InvalidEnumValue; * Schedule class. * * @category Calendar - * @package Framework + * @package Modules * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 @@ -30,32 +30,116 @@ use phpOMS\Datatypes\Exception\InvalidEnumValue; */ class Schedule { + /** + * Schedule ID. + * + * @var int + * @since 1.0.0 + */ private $id = 0; + /** + * Calendar uid. + * + * @var string + * @since 1.0.0 + */ private $uid = ''; + /** + * Schedule status. + * + * @var int + * @since 1.0.0 + */ private $status = ScheduleStatus::ACTIVE; + /** + * Frequency type. + * + * @var int + * @since 1.0.0 + */ private $freqType = FrequencyType::ONCE; + /** + * Frequency interval. + * + * @var int + * @since 1.0.0 + */ private $freqInterval = FrequencyInterval::DAY; + /** + * Frequency relative. + * + * @var int + * @since 1.0.0 + */ private $relativeInternal = FrequencyRelative::FIRST; + /** + * Interval type. + * + * @var int + * @since 1.0.0 + */ private $intervalType = IntervalType::ABSOLUTE; + /** + * Recurrence factor. + * + * @var int + * @since 1.0.0 + */ private $recurrenceFactor = 0; + /** + * Start. + * + * @var \DateTime + * @since 1.0.0 + */ private $start = null; + /** + * Duration. + * + * @var int + * @since 1.0.0 + */ private $duration = 3600; + /** + * End. + * + * @var \DateTime + * @since 1.0.0 + */ private $end = null; + /** + * Created at. + * + * @var \DateTime + * @since 1.0.0 + */ private $createdAt = null; + /** + * Created by. + * + * @var int + * @since 1.0.0 + */ private $createdBy = 0; + /** + * Constructor. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function __construct() { $this->createdAt = new \DateTime('now'); @@ -64,16 +148,36 @@ class Schedule $this->end->setTimestamp($this->end->getTimestamp() + $this->duration); } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getId() : int { return $this->id; } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getStatus() : int { return $this->status; } + /** + * @param int $status Schedule status + * + * @return $this + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setStatus(int $status) { if (!ScheduleStatus::isValidValue($status)) { @@ -85,11 +189,25 @@ class Schedule return $this; } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getFreqType() : int { return $this->freqType; } + /** + * @param int $freqType Frequency type + * + * @return $this + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setFreqType(int $freqType) { if (!FrequencyType::isValidValue($freqType)) { @@ -101,11 +219,25 @@ class Schedule return $this; } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getIntervalType() : int { return $this->intervalType; } + /** + * @param int $intervalType Interval type + * + * @return $this + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setIntervalType(int $intervalType) { if (!IntervalType::isValidValue($intervalType)) { @@ -117,22 +249,44 @@ class Schedule return $this; } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getFrequencyRelative() : int { return $this->relativeInternal; } - public function setFrequencyRelative(int $relativeInternal) + /** + * @param int $relativeInterval Relative interval + * + * @return $this + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setFrequencyRelative(int $relativeInterval) { - if (!FrequencyRelative::isValidValue($relativeInternal)) { - throw new InvalidEnumValue($relativeInternal); + if (!FrequencyRelative::isValidValue($relativeInterval)) { + throw new InvalidEnumValue($relativeInterval); } - $this->relativeInternal = $relativeInternal; + $this->relativeInternal = $relativeInterval; return $this; } + /** + * @param int $freqInterval Frequency interval + * + * @return $this + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setFreqInterval(int $freqInterval) { if (!FrequencyInterval::isValidValue($freqInterval)) { @@ -144,16 +298,36 @@ class Schedule return $this; } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getFreqInterval() : int { return $this->freqInterval; } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getRecurrenceFactor() : int { return $this->recurrenceFactor; } + /** + * @param int $recurrence Recurrence + * + * @return $this + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setRecurrenceFactor(int $recurrence) { $this->recurrenceFactor = $recurrence; @@ -161,11 +335,25 @@ class Schedule return $this; } + /** + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getStart() : \DateTime { return $this->start; } + /** + * @param \DateTime $start Schedule start + * + * @return $this + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setStart(\DateTime $start) { $this->start = $start; @@ -173,14 +361,28 @@ class Schedule return $this; } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getDuration() : int { return $this->duration; } + /** + * @param int $duration Duration + * + * @return $this + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setDuration(int $duration) { - if($duration < 1) { + if ($duration < 1) { throw new \InvalidArgumentException($duration); } @@ -189,11 +391,25 @@ class Schedule return $this; } + /** + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getEnd() : \DateTime { return $this->end; } + /** + * @param \DateTime $end Schedule end + * + * @return $this + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setEnd(\DateTime $end) { $this->end = $end; @@ -201,6 +417,14 @@ class Schedule return $this; } + /** + * @param int $creator Creator + * + * @return $this + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setCreatedBy(int $creator) { $this->createdBy = $creator; @@ -208,6 +432,12 @@ class Schedule return $this; } + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getCreatedBy() : int { return $this->createdBy; diff --git a/Models/ScheduleMapper.php b/Models/ScheduleMapper.php index c5676f7..6b6ee34 100644 --- a/Models/ScheduleMapper.php +++ b/Models/ScheduleMapper.php @@ -19,6 +19,17 @@ use phpOMS\DataStorage\Database\DataMapperAbstract; use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\DataStorage\Database\Query\Column; +/** + * Mapper class. + * + * @category Calendar + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ class ScheduleMapper extends DataMapperAbstract { @@ -44,9 +55,6 @@ class ScheduleMapper extends DataMapperAbstract 'scheule_created_by' => ['name' => 'scheule_created_by', 'type' => 'int', 'internal' => 'createdBy'], ]; - protected static $hasMany = [ - ]; - /** * Primary table. * @@ -55,6 +63,12 @@ class ScheduleMapper extends DataMapperAbstract */ protected static $table = 'schedule'; + /** + * Created at. + * + * @var string + * @since 1.0.0 + */ protected static $createdAt = 'schedule_created_at'; /** diff --git a/Models/ScheduleStatus.php b/Models/ScheduleStatus.php index b754887..3ea08a2 100644 --- a/Models/ScheduleStatus.php +++ b/Models/ScheduleStatus.php @@ -18,10 +18,10 @@ namespace Modules\Calendar\Models; use phpOMS\Datatypes\Enum; /** - * Occurrence type enum. + * Schedule status enum. * - * @category OccurrenceType - * @package Framework + * @category Calendar + * @package Modules * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0