cleanup and tests added for ci/cd

This commit is contained in:
Dennis Eichhorn 2019-11-20 22:28:04 +01:00
parent 8bf005b269
commit 5b5ded2fc1

View File

@ -87,6 +87,13 @@ class Promotion
private $tasks = []; private $tasks = [];
/**
* Cosntructor
*
* @param string $name Promotion name
*
* @since 1.0.0
*/
public function __construct(string $name = '') public function __construct(string $name = '')
{ {
$this->start = new \DateTime('now'); $this->start = new \DateTime('now');
@ -115,16 +122,41 @@ class Promotion
return $this->id; return $this->id;
} }
/**
* Get media files.
*
* @return array
*
* @since 1.0.0
*/
public function getMedia() : array public function getMedia() : array
{ {
return $this->media; return $this->media;
} }
/**
* Add media file.
*
* @param mixed $media Media
*
* @return void
*
* @since 1.0.0
*/
public function addMedia($media) : void public function addMedia($media) : void
{ {
$this->media[] = $media; $this->media[] = $media;
} }
/**
* Add task.
*
* @param Task $task Task
*
* @return void
*
* @since 1.0.0
*/
public function addTask(Task $task) : void public function addTask(Task $task) : void
{ {
if ($task->getId() !== 0) { if ($task->getId() !== 0) {
@ -134,6 +166,15 @@ class Promotion
} }
} }
/**
* Remove task
*
* @param int $id Id to remove.
*
* @return bool
*
* @since 1.0.0
*/
public function removeTask(int $id) : bool public function removeTask(int $id) : bool
{ {
if (isset($this->tasks[$id])) { if (isset($this->tasks[$id])) {
@ -145,61 +186,155 @@ class Promotion
return false; return false;
} }
/**
* Get task by id.
*
* @param int $id Task id
*
* @return Task
*
* @since 1.0.0
*/
public function getTask(int $id) : Task public function getTask(int $id) : Task
{ {
return $this->tasks[$id] ?? new Task(); return $this->tasks[$id] ?? new Task();
} }
/**
* Get tasks.
*
* @return array
*
* @since 1.0.0
*/
public function getTasks() : array public function getTasks() : array
{ {
return $this->tasks; return $this->tasks;
} }
/**
* Count tasks.
*
* @return int
*
* @since 1.0.0
*/
public function countTasks() : int public function countTasks() : int
{ {
return \count($this->tasks); return \count($this->tasks);
} }
/**
* Get start date.
*
* @return \DateTime
*
* @since 1.0.0
*/
public function getStart() : \DateTime public function getStart() : \DateTime
{ {
return $this->start; return $this->start;
} }
/**
* Set start date.
*
* @param \DateTime $start Start date
*
* @return void
*
* @since 1.0.0
*/
public function setStart(\DateTime $start) : void public function setStart(\DateTime $start) : void
{ {
$this->start = $start; $this->start = $start;
} }
/**
* Set end.
*
* @param \DateTime $end End date
*
* @return void
*
* @since 1.0.0
*/
public function setEnd(\DateTime $end) : void public function setEnd(\DateTime $end) : void
{ {
$this->end = $end; $this->end = $end;
} }
/**
* Get end.
*
* @return \DateTime
*
* @since 1.0.0
*/
public function getEnd() : \DateTime public function getEnd() : \DateTime
{ {
return $this->end; return $this->end;
} }
/**
* Get progress.
*
* @return int
*
* @since 1.0.0
*/
public function getProgress() : int public function getProgress() : int
{ {
return $this->progress; return $this->progress;
} }
/**
* Set progress.
*
* @param int $progress Progress
*
* @return void
*
* @since 1.0.0
*/
public function setProgress(int $progress) : void public function setProgress(int $progress) : void
{ {
$this->progress = $progress; $this->progress = $progress;
} }
/**
* Get progress type.
*
* @return int
*
* @since 1.0.0
*/
public function getProgressType() : int public function getProgressType() : int
{ {
return $this->progressType; return $this->progressType;
} }
/**
* Set progress type.
*
* @param int $type Progress type
*
* @return void
*
* @since 1.0.0
*/
public function setProgressType(int $type) : void public function setProgressType(int $type) : void
{ {
$this->progressType = $type; $this->progressType = $type;
} }
/**
* Get calendar.
*
* @return Calendar
*
* @since 1.0.0
*/
public function getCalendar() : Calendar public function getCalendar() : Calendar
{ {
return $this->calendar; return $this->calendar;
@ -258,37 +393,87 @@ class Promotion
$this->description = $description; $this->description = $description;
} }
/**
* Get costs.
*
* @return Money
*
* @since 1.0.0
*/
public function getCosts() : Money public function getCosts() : Money
{ {
return $this->costs; return $this->costs;
} }
/**
* Get budget.
*
* @return Money
*
* @since 1.0.0
*/
public function getBudget() : Money public function getBudget() : Money
{ {
return $this->budget; return $this->budget;
} }
/**
* Get earnings.
*
* @return Money
*
* @since 1.0.0
*/
public function getEarnings() : Money public function getEarnings() : Money
{ {
return $this->earnings; return $this->earnings;
} }
/**
* Set costs.
*
* @param Money $costs Costs
*
* @return void
*
* @since 1.0.0
*/
public function setCosts(Money $costs) : void public function setCosts(Money $costs) : void
{ {
$this->costs = $costs; $this->costs = $costs;
} }
/**
* Set budget.
*
* @param Money $budget Budget
*
* @return void
*
* @since 1.0.0
*/
public function setBudget(Money $budget) : void public function setBudget(Money $budget) : void
{ {
$this->budget = $budget; $this->budget = $budget;
} }
/**
* Set earnings.
*
* @param Money $earnings Earnings
*
* @return void
*
* @since 1.0.0
*/
public function setEarnings(Money $earnings) : void public function setEarnings(Money $earnings) : void
{ {
$this->earnings = $earnings; $this->earnings = $earnings;
} }
/** /**
* Get created at
*
* @return \DateTime * @return \DateTime
* *
* @since 1.0.0 * @since 1.0.0
@ -299,6 +484,8 @@ class Promotion
} }
/** /**
* Get created by
*
* @return int * @return int
* *
* @since 1.0.0 * @since 1.0.0
@ -309,7 +496,9 @@ class Promotion
} }
/** /**
* @param $createdBy Creator * Set creator
*
* @param int $createdBy Creator
* *
* @since 1.0.0 * @since 1.0.0
*/ */