From 575bafa380fda8bcc2b2373af883f21c989bb49c Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 6 Oct 2019 17:50:12 +0200 Subject: [PATCH] phpcs fixes --- Controller/ApiController.php | 93 ++++++++++++++++++++ Models/QAAnswer.php | 36 +++++++- Models/QACategory.php | 44 ++++++++-- Models/QAQuestion.php | 100 ++++++++++++++++++++-- Theme/Backend/Lang/Navigation.en.lang.php | 4 +- Theme/Backend/Lang/en.lang.php | 4 +- Theme/Backend/qa-tag-edit.tpl.php | 4 +- Theme/Backend/qa-tag-list.tpl.php | 4 +- 8 files changed, 271 insertions(+), 18 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 51bcb70..220bd57 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -28,6 +28,19 @@ use phpOMS\Message\ResponseAbstract; */ final class ApiController extends Controller { + /** + * Api method to create a question + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ public function apiQAQuestionCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void { if (!empty($val = $this->validateQAQuestionCreate($request))) { @@ -41,6 +54,15 @@ final class ApiController extends Controller $response->set('question', $question->jsonSerialize()); } + /** + * Method to create question from request. + * + * @param RequestAbstract $request Request + * + * @return QAQuestion Returns the created question from the request + * + * @since 1.0.0 + */ public function createQAQuestionFromRquest(RequestAbstract $request) : QAQuestion { $mardkownParser = new Markdown(); @@ -56,6 +78,15 @@ final class ApiController extends Controller return $question; } + /** + * Validate question create request + * + * @param RequestAbstract $request Request + * + * @return array Returns the validation array of the request + * + * @since 1.0.0 + */ private function validateQAQuestionCreate(RequestAbstract $request) : array { $val = []; @@ -75,6 +106,19 @@ final class ApiController extends Controller return []; } + /** + * Api method to create a answer + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ public function apiQAAnswerCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void { if (!empty($val = $this->validateQAAnswerCreate($request))) { @@ -88,6 +132,15 @@ final class ApiController extends Controller $response->set('answer', $answer->jsonSerialize()); } + /** + * Method to create answer from request. + * + * @param RequestAbstract $request Request + * + * @return QAAnswer Returns the created answer from the request + * + * @since 1.0.0 + */ public function createQAAnswerFromRquest(RequestAbstract $request) : QAAnswer { $mardkownParser = new Markdown(); @@ -101,6 +154,15 @@ final class ApiController extends Controller return $answer; } + /** + * Validate answer create request + * + * @param RequestAbstract $request Request + * + * @return array Returns the validation array of the request + * + * @since 1.0.0 + */ private function validateQAAnswerCreate(RequestAbstract $request) : array { $val = []; @@ -118,6 +180,19 @@ final class ApiController extends Controller return []; } + /** + * Api method to create a category + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ public function apiQACategoryCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void { if (!empty($val = $this->validateQACategoryCreate($request))) { @@ -131,6 +206,15 @@ final class ApiController extends Controller $response->set('category', $category->jsonSerialize()); } + /** + * Method to create category from request. + * + * @param RequestAbstract $request Request + * + * @return QACategory Returns the created category from the request + * + * @since 1.0.0 + */ public function createQACategoryFromRquest(RequestAbstract $request) : QACategory { $mardkownParser = new Markdown(); @@ -142,6 +226,15 @@ final class ApiController extends Controller return $category; } + /** + * Validate category create request + * + * @param RequestAbstract $request Request + * + * @return array Returns the validation array of the request + * + * @since 1.0.0 + */ private function validateQACategoryCreate(RequestAbstract $request) : array { $val = []; diff --git a/Models/QAAnswer.php b/Models/QAAnswer.php index 7b01c6b..a2b8dd1 100644 --- a/Models/QAAnswer.php +++ b/Models/QAAnswer.php @@ -24,9 +24,15 @@ namespace Modules\QA\Models; */ class QAAnswer implements \JsonSerializable { - private $id = 0; + /** + * ID. + * + * @var int + * @since 1.0.0 + */ + protected int $id = 0; - private $status = QAAnswerStatus::ACTIVE; + private int $status = QAAnswerStatus::ACTIVE; private $answer = ''; @@ -38,11 +44,23 @@ class QAAnswer implements \JsonSerializable private $createdAt = null; + /** + * Constructor. + * + * @since 1.0.0 + */ public function __construct() { $this->createdAt = new \DateTime('now'); } + /** + * Get id. + * + * @return int Model id + * + * @since 1.0.0 + */ public function getId() : int { return $this->id; @@ -88,6 +106,13 @@ class QAAnswer implements \JsonSerializable return $this->isAccepted; } + /** + * Get created by + * + * @return int|\phpOMS\Account\Account + * + * @since 1.0.0 + */ public function getCreatedBy() { return $this->createdBy; @@ -98,6 +123,13 @@ class QAAnswer implements \JsonSerializable $this->createdBy = $id; } + /** + * Get created at date time + * + * @return \DateTime + * + * @since 1.0.0 + */ public function getCreatedAt() : \DateTime { return $this->createdAt; diff --git a/Models/QACategory.php b/Models/QACategory.php index b970b3a..b5f1c9a 100644 --- a/Models/QACategory.php +++ b/Models/QACategory.php @@ -24,26 +24,56 @@ namespace Modules\QA\Models; */ class QACategory implements \JsonSerializable { - private $id = 0; - - private $name = ''; + /** + * ID. + * + * @var int + * @since 1.0.0 + */ + protected int $id = 0; + /** + * Name. + * + * @var string + * @since 1.0.0 + */ + private string $name = ''; private $parent = null; - public function __construct() - { - } - + /** + * Get id. + * + * @return int Model id + * + * @since 1.0.0 + */ public function getId() : int { return $this->id; } + /** + * Get name + * + * @return string + * + * @since 1.0.0 + */ public function getName() : string { return $this->name; } + /** + * Set name + * + * @param string $name Name + * + * @return void + * + * @since 1.0.0 + */ public function setName(string $name) : void { $this->name = $name; diff --git a/Models/QAQuestion.php b/Models/QAQuestion.php index 857f1b7..be54ae2 100644 --- a/Models/QAQuestion.php +++ b/Models/QAQuestion.php @@ -24,11 +24,22 @@ namespace Modules\QA\Models; */ class QAQuestion implements \JsonSerializable { - private $id = 0; + /** + * ID. + * + * @var int + * @since 1.0.0 + */ + protected int $id = 0; + /** + * Name. + * + * @var string + * @since 1.0.0 + */ + private string $name = ''; - private $name = ''; - - private $status = QAQuestionStatus::ACTIVE; + private int $status = QAQuestionStatus::ACTIVE; private $question = ''; @@ -44,11 +55,23 @@ class QAQuestion implements \JsonSerializable private $answers = []; + /** + * Constructor. + * + * @since 1.0.0 + */ public function __construct() { $this->createdAt = new \DateTime('now'); } + /** + * Get id. + * + * @return int Model id + * + * @since 1.0.0 + */ public function getId() : int { return $this->id; @@ -86,11 +109,27 @@ class QAQuestion implements \JsonSerializable return false; } + /** + * Get name + * + * @return string + * + * @since 1.0.0 + */ public function getName() : string { return $this->name; } + /** + * Set name + * + * @param string $name Name + * + * @return void + * + * @since 1.0.0 + */ public function setName(string $name) : void { $this->name = $name; @@ -126,36 +165,87 @@ class QAQuestion implements \JsonSerializable $this->category = $category; } + /** + * Get created by + * + * @return int|\phpOMS\Account\Account + * + * @since 1.0.0 + */ public function getCreatedBy() { return $this->createdBy; } - public function setCreatedBy(int $id) : void + /** + * Set created by + * + * @param mixed $id Created by + * + * @return void + * + * @since 1.0.0 + */ + public function setCreatedBy($id) : void { $this->createdBy = $id; } + /** + * Get created at date time + * + * @return \DateTime + * + * @since 1.0.0 + */ public function getCreatedAt() : \DateTime { return $this->createdAt; } + /** + * Get badges + * + * @return array + * + * @since 1.0.0 + */ public function getBadges() : array { return $this->badges; } + /** + * Add badge to question + * + * @param int|QABadge $badge Badge + */ public function addBadge($badge) : void { $this->badges[] = $badge; } + /** + * Get answers + * + * @return array + * + * @since 1.0.0 + */ public function getAnswers() : array { return $this->answers; } + /** + * Add answer to question + * + * @param int|QAAnswer $answer Answer to the question + * + * @return void + * + * @since 1.0.0 + */ public function addAnswer($answer) : void { $this->answers[] = $answer; diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php index e1dbd03..d4c9a12 100644 --- a/Theme/Backend/Lang/Navigation.en.lang.php +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -1,4 +1,4 @@ - [ 'Badges' => 'Badges', 'QA' => 'QA', diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index dedb807..a0381c3 100644 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -1,4 +1,4 @@ - [ 'Badges' => 'Badges', 'List' => 'List', diff --git a/Theme/Backend/qa-tag-edit.tpl.php b/Theme/Backend/qa-tag-edit.tpl.php index 7b42f29..be3fc48 100644 --- a/Theme/Backend/qa-tag-edit.tpl.php +++ b/Theme/Backend/qa-tag-edit.tpl.php @@ -1,4 +1,4 @@ -getData('tag'); diff --git a/Theme/Backend/qa-tag-list.tpl.php b/Theme/Backend/qa-tag-list.tpl.php index f8aa758..399c75a 100644 --- a/Theme/Backend/qa-tag-list.tpl.php +++ b/Theme/Backend/qa-tag-list.tpl.php @@ -1,4 +1,4 @@ -getData('tags');