From dfb15ac6556ebf38b0943bea51f57506680344f3 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 6 Oct 2019 17:50:12 +0200 Subject: [PATCH] phpcs fixes --- Admin/Install/db.json | 5 + Models/NullProject.php | 27 + Models/Project.php | 504 +++++++++++++++++- Models/ProjectMapper.php | 29 +- Theme/Backend/Lang/Navigation.en.lang.php | 4 +- Theme/Backend/Lang/api.en.lang.php | 4 +- Theme/Backend/Lang/en.lang.php | 4 +- .../Backend/projectmanagement-create.tpl.php | 4 +- Theme/Backend/projectmanagement-list.tpl.php | 4 +- .../Backend/projectmanagement-profile.tpl.php | 4 +- 10 files changed, 548 insertions(+), 41 deletions(-) create mode 100644 Models/NullProject.php diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 1e62211..fb357bb 100644 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -19,6 +19,11 @@ "type": "TEXT", "null": true }, + "projectmanagement_project_description_raw": { + "name": "projectmanagement_project_description_raw", + "type": "TEXT", + "null": true + }, "projectmanagement_project_calendar": { "name": "projectmanagement_project_calendar", "type": "INT", diff --git a/Models/NullProject.php b/Models/NullProject.php new file mode 100644 index 0000000..f6c0273 --- /dev/null +++ b/Models/NullProject.php @@ -0,0 +1,27 @@ +start = new \DateTime('now'); $this->end = new \DateTime('now'); $this->end->modify('+1 month'); - $this->createdAt = new \DateTime('now'); + + $this->estimatedEnd = clone $this->end; + $this->createdAt = new \DateTime('now'); $this->calendar = new Calendar(); @@ -86,21 +197,77 @@ class Project $this->setName($name); } + /** + * Get id. + * + * @return int + * + * @since 1.0.0 + */ public function getId() : int { return $this->id; } - public function getMedia() : array + /** + * Get all media files. + * + * @return Media[] + * + * @since 1.0.0 + */ + public function getMedias() : array { return $this->media; } + /** + * Add media + * + * @param int|Media $media Media + * + * @return void + * + * @since 1.0.0 + */ public function addMedia($media) : void { - $this->media[] = $media; + if ($media->getId() !== 0) { + $this->media[$media->getId()] = $media; + } else { + $this->media[] = $media; + } } + /** + * Remove media + * + * @param int $id Media id + * + * @return bool + * + * @since 1.0.0 + */ + public function removeMedia(int $id) : bool + { + if (isset($this->media[$id])) { + unset($this->media[$id]); + + return true; + } + + return false; + } + + /** + * Add task + * + * @param int|Task $task Task + * + * @return void + * + * @since 1.0.0 + */ public function addTask(Task $task) : void { if ($task->getId() !== 0) { @@ -110,6 +277,15 @@ class Project } } + /** + * Remove task + * + * @param int $id Task id + * + * @return bool + * + * @since 1.0.0 + */ public function removeTask(int $id) : bool { if (isset($this->tasks[$id])) { @@ -121,118 +297,398 @@ class Project return false; } + /** + * Get progress + * + * @return int + * + * @since 1.0.0 + */ public function getProgress() : int { return $this->progress; } + /** + * Set progress + * + * @param int $progress Progress + * + * @return void + * + * @since 1.0.0 + */ public function setProgress(int $progress) : void { $this->progress = $progress; } + /** + * Get progress type + * + * @return int + * + * @since 1.0.0 + */ public function getProgressType() : int { return $this->progressType; } + /** + * Set progress type + * + * @param int $type Progress type + * + * @return void + * + * @since 1.0.0 + */ public function setProgressType(int $type) : void { $this->progressType = $type; } + /** + * Get task + * + * @param int $id Task id + * + * @return Task + * + * @since 1.0.0 + */ public function getTask(int $id) : Task { return $this->tasks[$id] ?? new Task(); } + /** + * Get media + * + * @param int $id Media id + * + * @return Media + * + * @since 1.0.0 + */ + public function getMedia(int $id) : Media + { + return $this->media[$id] ?? new Task(); + } + + /** + * Get tasks + * + * @return Task[] + * + * @since 1.0.0 + */ public function getTasks() : array { return $this->tasks; } + /** + * Count tasks + * + * @return int + * + * @since 1.0.0 + */ public function countTasks() : int { return \count($this->tasks); } + /** + * Count media + * + * @return int + * + * @since 1.0.0 + */ + public function countMedia() : int + { + return \count($this->media); + } + + /** + * Get start date + * + * @return \DateTime + * + * @since 1.0.0 + */ public function getStart() : \DateTime { return $this->start; } + /** + * Set start date + * + * @param \DateTime $start Start date + * + * @return void + * + * @since 1.0.0 + */ public function setStart(\DateTime $start) : void { $this->start = $start; } + /** + * Set end date + * + * @param \DateTime $end End date + * + * @return void + * + * @since 1.0.0 + */ public function setEnd(\DateTime $end) : void { $this->end = $end; } + /** + * Get end date + * + * @return \DateTime + * + * @since 1.0.0 + */ public function getEnd() : \DateTime { return $this->end; } + /** + * Set estimated end date + * + * @param \DateTime $end End date + * + * @return void + * + * @since 1.0.0 + */ + public function setEstimatedEnd(\DateTime $end) : void + { + $this->end = $end; + } + + /** + * Get estimated end date + * + * @return \DateTime + * + * @since 1.0.0 + */ + public function getEstimatedEnd() : \DateTime + { + return $this->end; + } + + /** + * Get calendar + * + * @return Calendar + * + * @since 1.0.0 + */ public function getCalendar() : Calendar { return $this->calendar; } + /** + * Get name + * + * @return string + * + * @since 1.0.0 + */ public function getName() : string { return $this->name; } + /** + * Set name + * + * @param string $name Project name + * + * @return void + * + * @since 1.0.0 + */ public function setName(string $name) : void { $this->name = $name; $this->calendar->setName($name); } + /** + * Get description + * + * @return string + * + * @since 1.0.0 + */ public function getDescription() : string { return $this->description; } + /** + * Set Description + * + * @param string $description Description + * + * @return void + * + * @since 1.0.0 + */ public function setDescription(string $description) : void { $this->description = $description; } + /** + * Get description + * + * @return string + * + * @since 1.0.0 + */ + public function getDescriptionRaw() : string + { + return $this->descriptionRaw; + } + + /** + * Set Description + * + * @param string $description Description + * + * @return void + * + * @since 1.0.0 + */ + public function setDescriptionRaw(string $description) : void + { + $this->descriptionRaw = $description; + } + + /** + * Get costs + * + * @return Money + * + * @sicne 1.0.0 + */ public function getCosts() : Money { return $this->costs; } - public function getBudget() : Money + /** + * Get budget costs + * + * @return Money + * + * @sicne 1.0.0 + */ + public function getBudgetCosts() : Money { - return $this->budget; + return $this->budgetCosts; } + /** + * Get budget earnings + * + * @return Money + * + * @sicne 1.0.0 + */ + public function getBudgetEarnings() : Money + { + return $this->budgetEarnings; + } + + /** + * Get earnings + * + * @return Money + * + * @sicne 1.0.0 + */ public function getEarnings() : Money { return $this->earnings; } + /** + * Set costs + * + * @param Money $costs Costs + * + * @return void + * + * @since 1.0.0 + */ public function setCosts(Money $costs) : void { $this->costs = $costs; } - public function setBudget(Money $budget) : void + /** + * Set budget costs + * + * @param Money $budget Budget + * + * @return void + * + * @since 1.0.0 + */ + public function setBudgetCosts(Money $budget) : void { - $this->budget = $budget; + $this->budgetCosts = $budget; } + /** + * Set budget earnings + * + * @param Money $budget Budget + * + * @return void + * + * @since 1.0.0 + */ + public function setBudgetEarnings(Money $budget) : void + { + $this->budgetEarnings = $budget; + } + + /** + * Set earnings + * + * @param Money $earnings Earnings + * + * @return void + * + * @since 1.0.0 + */ public function setEarnings(Money $earnings) : void { $this->earnings = $earnings; } /** + * Get created at + * * @return \DateTime * * @since 1.0.0 @@ -243,6 +699,8 @@ class Project } /** + * Get created by + * * @return int * * @since 1.0.0 @@ -253,7 +711,9 @@ class Project } /** - * @param $createdBy Creator + * Set created by + * + * @param int $createdBy Creator * * @since 1.0.0 */ diff --git a/Models/ProjectMapper.php b/Models/ProjectMapper.php index 95215d9..6623e2a 100644 --- a/Models/ProjectMapper.php +++ b/Models/ProjectMapper.php @@ -37,19 +37,22 @@ final class ProjectMapper extends DataMapperAbstract * @since 1.0.0 */ protected static array $columns = [ - 'projectmanagement_project_id' => ['name' => 'projectmanagement_project_id', 'type' => 'int', 'internal' => 'id'], - 'projectmanagement_project_name' => ['name' => 'projectmanagement_project_name', 'type' => 'string', 'internal' => 'name'], - 'projectmanagement_project_description' => ['name' => 'projectmanagement_project_description', 'type' => 'string', 'internal' => 'description'], - 'projectmanagement_project_calendar' => ['name' => 'projectmanagement_project_calendar', 'type' => 'int', 'internal' => 'calendar'], - 'projectmanagement_project_costs' => ['name' => 'projectmanagement_project_costs', 'type' => 'Serializable', 'internal' => 'costs'], - 'projectmanagement_project_budget' => ['name' => 'projectmanagement_project_budget', 'type' => 'Serializable', 'internal' => 'budget'], - 'projectmanagement_project_earnings' => ['name' => 'projectmanagement_project_earnings', 'type' => 'Serializable', 'internal' => 'earnings'], - 'projectmanagement_project_start' => ['name' => 'projectmanagement_project_start', 'type' => 'DateTime', 'internal' => 'start'], - 'projectmanagement_project_end' => ['name' => 'projectmanagement_project_end', 'type' => 'DateTime', 'internal' => 'end'], - 'projectmanagement_project_progress' => ['name' => 'projectmanagement_project_progress', 'type' => 'int', 'internal' => 'progress'], - 'projectmanagement_project_progress_type' => ['name' => 'projectmanagement_project_progress_type', 'type' => 'int', 'internal' => 'progressType'], - 'projectmanagement_project_created_by' => ['name' => 'projectmanagement_project_created_by', 'type' => 'int', 'internal' => 'createdBy'], - 'projectmanagement_project_created_at' => ['name' => 'projectmanagement_project_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], + 'projectmanagement_project_id' => ['name' => 'projectmanagement_project_id', 'type' => 'int', 'internal' => 'id'], + 'projectmanagement_project_name' => ['name' => 'projectmanagement_project_name', 'type' => 'string', 'internal' => 'name'], + 'projectmanagement_project_description' => ['name' => 'projectmanagement_project_description', 'type' => 'string', 'internal' => 'description'], + 'projectmanagement_project_description_raw' => ['name' => 'projectmanagement_project_description_raw', 'type' => 'string', 'internal' => 'descriptionRaw'], + 'projectmanagement_project_calendar' => ['name' => 'projectmanagement_project_calendar', 'type' => 'int', 'internal' => 'calendar'], + 'projectmanagement_project_costs' => ['name' => 'projectmanagement_project_costs', 'type' => 'Serializable', 'internal' => 'costs'], + 'projectmanagement_project_budgetcosts' => ['name' => 'projectmanagement_project_budgetcosts', 'type' => 'Serializable', 'internal' => 'budgetCosts'], + 'projectmanagement_project_budgetearnings' => ['name' => 'projectmanagement_project_budgetearnings', 'type' => 'Serializable', 'internal' => 'budgetEarnings'], + 'projectmanagement_project_earnings' => ['name' => 'projectmanagement_project_earnings', 'type' => 'Serializable', 'internal' => 'earnings'], + 'projectmanagement_project_start' => ['name' => 'projectmanagement_project_start', 'type' => 'DateTime', 'internal' => 'start'], + 'projectmanagement_project_end' => ['name' => 'projectmanagement_project_end', 'type' => 'DateTime', 'internal' => 'end'], + 'projectmanagement_project_endestimated' => ['name' => 'projectmanagement_project_endestimated', 'type' => 'DateTime', 'internal' => 'endEstimated'], + 'projectmanagement_project_progress' => ['name' => 'projectmanagement_project_progress', 'type' => 'int', 'internal' => 'progress'], + 'projectmanagement_project_progress_type' => ['name' => 'projectmanagement_project_progress_type', 'type' => 'int', 'internal' => 'progressType'], + 'projectmanagement_project_created_by' => ['name' => 'projectmanagement_project_created_by', 'type' => 'int', 'internal' => 'createdBy'], + 'projectmanagement_project_created_at' => ['name' => 'projectmanagement_project_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], ]; /** diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php index 9c68cf2..364233d 100644 --- a/Theme/Backend/Lang/Navigation.en.lang.php +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -1,4 +1,4 @@ - [ 'ProjectManagement' => 'Project Management', ]]; diff --git a/Theme/Backend/Lang/api.en.lang.php b/Theme/Backend/Lang/api.en.lang.php index 9623f85..1652678 100644 --- a/Theme/Backend/Lang/api.en.lang.php +++ b/Theme/Backend/Lang/api.en.lang.php @@ -1,4 +1,4 @@ - [ 'Active' => 'Active', 'Actual' => 'Actual', diff --git a/Theme/Backend/projectmanagement-create.tpl.php b/Theme/Backend/projectmanagement-create.tpl.php index bad6e14..40a1130 100644 --- a/Theme/Backend/projectmanagement-create.tpl.php +++ b/Theme/Backend/projectmanagement-create.tpl.php @@ -1,4 +1,4 @@ -getData('nav')->render(); ?> diff --git a/Theme/Backend/projectmanagement-list.tpl.php b/Theme/Backend/projectmanagement-list.tpl.php index 544f723..71c9c08 100644 --- a/Theme/Backend/projectmanagement-list.tpl.php +++ b/Theme/Backend/projectmanagement-list.tpl.php @@ -1,4 +1,4 @@ -app, $this->request, $this->response); $footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); diff --git a/Theme/Backend/projectmanagement-profile.tpl.php b/Theme/Backend/projectmanagement-profile.tpl.php index e87f78f..c25c8ad 100644 --- a/Theme/Backend/projectmanagement-profile.tpl.php +++ b/Theme/Backend/projectmanagement-profile.tpl.php @@ -1,4 +1,4 @@ -getData('project'); echo $this->getData('nav')->render(); ?>