mirror of
https://github.com/Karaka-Management/oms-QA.git
synced 2026-02-15 23:38:41 +00:00
phpcs fixes
This commit is contained in:
parent
bcaff0a770
commit
575bafa380
|
|
@ -28,6 +28,19 @@ use phpOMS\Message\ResponseAbstract;
|
||||||
*/
|
*/
|
||||||
final class ApiController extends Controller
|
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
|
public function apiQAQuestionCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||||
{
|
{
|
||||||
if (!empty($val = $this->validateQAQuestionCreate($request))) {
|
if (!empty($val = $this->validateQAQuestionCreate($request))) {
|
||||||
|
|
@ -41,6 +54,15 @@ final class ApiController extends Controller
|
||||||
$response->set('question', $question->jsonSerialize());
|
$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
|
public function createQAQuestionFromRquest(RequestAbstract $request) : QAQuestion
|
||||||
{
|
{
|
||||||
$mardkownParser = new Markdown();
|
$mardkownParser = new Markdown();
|
||||||
|
|
@ -56,6 +78,15 @@ final class ApiController extends Controller
|
||||||
return $question;
|
return $question;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate question create request
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
*
|
||||||
|
* @return array<string, bool> Returns the validation array of the request
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function validateQAQuestionCreate(RequestAbstract $request) : array
|
private function validateQAQuestionCreate(RequestAbstract $request) : array
|
||||||
{
|
{
|
||||||
$val = [];
|
$val = [];
|
||||||
|
|
@ -75,6 +106,19 @@ final class ApiController extends Controller
|
||||||
return [];
|
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
|
public function apiQAAnswerCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||||
{
|
{
|
||||||
if (!empty($val = $this->validateQAAnswerCreate($request))) {
|
if (!empty($val = $this->validateQAAnswerCreate($request))) {
|
||||||
|
|
@ -88,6 +132,15 @@ final class ApiController extends Controller
|
||||||
$response->set('answer', $answer->jsonSerialize());
|
$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
|
public function createQAAnswerFromRquest(RequestAbstract $request) : QAAnswer
|
||||||
{
|
{
|
||||||
$mardkownParser = new Markdown();
|
$mardkownParser = new Markdown();
|
||||||
|
|
@ -101,6 +154,15 @@ final class ApiController extends Controller
|
||||||
return $answer;
|
return $answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate answer create request
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
*
|
||||||
|
* @return array<string, bool> Returns the validation array of the request
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function validateQAAnswerCreate(RequestAbstract $request) : array
|
private function validateQAAnswerCreate(RequestAbstract $request) : array
|
||||||
{
|
{
|
||||||
$val = [];
|
$val = [];
|
||||||
|
|
@ -118,6 +180,19 @@ final class ApiController extends Controller
|
||||||
return [];
|
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
|
public function apiQACategoryCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||||
{
|
{
|
||||||
if (!empty($val = $this->validateQACategoryCreate($request))) {
|
if (!empty($val = $this->validateQACategoryCreate($request))) {
|
||||||
|
|
@ -131,6 +206,15 @@ final class ApiController extends Controller
|
||||||
$response->set('category', $category->jsonSerialize());
|
$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
|
public function createQACategoryFromRquest(RequestAbstract $request) : QACategory
|
||||||
{
|
{
|
||||||
$mardkownParser = new Markdown();
|
$mardkownParser = new Markdown();
|
||||||
|
|
@ -142,6 +226,15 @@ final class ApiController extends Controller
|
||||||
return $category;
|
return $category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate category create request
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
*
|
||||||
|
* @return array<string, bool> Returns the validation array of the request
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function validateQACategoryCreate(RequestAbstract $request) : array
|
private function validateQACategoryCreate(RequestAbstract $request) : array
|
||||||
{
|
{
|
||||||
$val = [];
|
$val = [];
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,15 @@ namespace Modules\QA\Models;
|
||||||
*/
|
*/
|
||||||
class QAAnswer implements \JsonSerializable
|
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 = '';
|
private $answer = '';
|
||||||
|
|
||||||
|
|
@ -38,11 +44,23 @@ class QAAnswer implements \JsonSerializable
|
||||||
|
|
||||||
private $createdAt = null;
|
private $createdAt = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->createdAt = new \DateTime('now');
|
$this->createdAt = new \DateTime('now');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id.
|
||||||
|
*
|
||||||
|
* @return int Model id
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getId() : int
|
public function getId() : int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|
@ -88,6 +106,13 @@ class QAAnswer implements \JsonSerializable
|
||||||
return $this->isAccepted;
|
return $this->isAccepted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get created by
|
||||||
|
*
|
||||||
|
* @return int|\phpOMS\Account\Account
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getCreatedBy()
|
public function getCreatedBy()
|
||||||
{
|
{
|
||||||
return $this->createdBy;
|
return $this->createdBy;
|
||||||
|
|
@ -98,6 +123,13 @@ class QAAnswer implements \JsonSerializable
|
||||||
$this->createdBy = $id;
|
$this->createdBy = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get created at date time
|
||||||
|
*
|
||||||
|
* @return \DateTime
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getCreatedAt() : \DateTime
|
public function getCreatedAt() : \DateTime
|
||||||
{
|
{
|
||||||
return $this->createdAt;
|
return $this->createdAt;
|
||||||
|
|
|
||||||
|
|
@ -24,26 +24,56 @@ namespace Modules\QA\Models;
|
||||||
*/
|
*/
|
||||||
class QACategory implements \JsonSerializable
|
class QACategory implements \JsonSerializable
|
||||||
{
|
{
|
||||||
private $id = 0;
|
/**
|
||||||
|
* ID.
|
||||||
private $name = '';
|
*
|
||||||
|
* @var int
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected int $id = 0;
|
||||||
|
/**
|
||||||
|
* Name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private string $name = '';
|
||||||
|
|
||||||
private $parent = null;
|
private $parent = null;
|
||||||
|
|
||||||
public function __construct()
|
/**
|
||||||
{
|
* Get id.
|
||||||
}
|
*
|
||||||
|
* @return int Model id
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getId() : int
|
public function getId() : int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getName() : string
|
public function getName() : string
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set name
|
||||||
|
*
|
||||||
|
* @param string $name Name
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function setName(string $name) : void
|
public function setName(string $name) : void
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,22 @@ namespace Modules\QA\Models;
|
||||||
*/
|
*/
|
||||||
class QAQuestion implements \JsonSerializable
|
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 int $status = QAQuestionStatus::ACTIVE;
|
||||||
|
|
||||||
private $status = QAQuestionStatus::ACTIVE;
|
|
||||||
|
|
||||||
private $question = '';
|
private $question = '';
|
||||||
|
|
||||||
|
|
@ -44,11 +55,23 @@ class QAQuestion implements \JsonSerializable
|
||||||
|
|
||||||
private $answers = [];
|
private $answers = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->createdAt = new \DateTime('now');
|
$this->createdAt = new \DateTime('now');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id.
|
||||||
|
*
|
||||||
|
* @return int Model id
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getId() : int
|
public function getId() : int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|
@ -86,11 +109,27 @@ class QAQuestion implements \JsonSerializable
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getName() : string
|
public function getName() : string
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set name
|
||||||
|
*
|
||||||
|
* @param string $name Name
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function setName(string $name) : void
|
public function setName(string $name) : void
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
|
@ -126,36 +165,87 @@ class QAQuestion implements \JsonSerializable
|
||||||
$this->category = $category;
|
$this->category = $category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get created by
|
||||||
|
*
|
||||||
|
* @return int|\phpOMS\Account\Account
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getCreatedBy()
|
public function getCreatedBy()
|
||||||
{
|
{
|
||||||
return $this->createdBy;
|
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;
|
$this->createdBy = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get created at date time
|
||||||
|
*
|
||||||
|
* @return \DateTime
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getCreatedAt() : \DateTime
|
public function getCreatedAt() : \DateTime
|
||||||
{
|
{
|
||||||
return $this->createdAt;
|
return $this->createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get badges
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getBadges() : array
|
public function getBadges() : array
|
||||||
{
|
{
|
||||||
return $this->badges;
|
return $this->badges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add badge to question
|
||||||
|
*
|
||||||
|
* @param int|QABadge $badge Badge
|
||||||
|
*/
|
||||||
public function addBadge($badge) : void
|
public function addBadge($badge) : void
|
||||||
{
|
{
|
||||||
$this->badges[] = $badge;
|
$this->badges[] = $badge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get answers
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getAnswers() : array
|
public function getAnswers() : array
|
||||||
{
|
{
|
||||||
return $this->answers;
|
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
|
public function addAnswer($answer) : void
|
||||||
{
|
{
|
||||||
$this->answers[] = $answer;
|
$this->answers[] = $answer;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<?php declare(strict_types=1);
|
<?php
|
||||||
/**
|
/**
|
||||||
* Orange Management
|
* Orange Management
|
||||||
*
|
*
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link https://orange-management.org
|
* @link https://orange-management.org
|
||||||
*/
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
return ['Navigation' => [
|
return ['Navigation' => [
|
||||||
'Badges' => 'Badges',
|
'Badges' => 'Badges',
|
||||||
'QA' => 'QA',
|
'QA' => 'QA',
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<?php declare(strict_types=1);
|
<?php
|
||||||
/**
|
/**
|
||||||
* Orange Management
|
* Orange Management
|
||||||
*
|
*
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link https://orange-management.org
|
* @link https://orange-management.org
|
||||||
*/
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
return ['QA' => [
|
return ['QA' => [
|
||||||
'Badges' => 'Badges',
|
'Badges' => 'Badges',
|
||||||
'List' => 'List',
|
'List' => 'List',
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<?php declare(strict_types=1);
|
<?php
|
||||||
/**
|
/**
|
||||||
* Orange Management
|
* Orange Management
|
||||||
*
|
*
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link https://orange-management.org
|
* @link https://orange-management.org
|
||||||
*/
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
$tag = $this->getData('tag');
|
$tag = $this->getData('tag');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<?php declare(strict_types=1);
|
<?php
|
||||||
/**
|
/**
|
||||||
* Orange Management
|
* Orange Management
|
||||||
*
|
*
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link https://orange-management.org
|
* @link https://orange-management.org
|
||||||
*/
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
$tags = $this->getData('tags');
|
$tags = $this->getData('tags');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user