mirror of
https://github.com/Karaka-Management/oms-QA.git
synced 2026-02-01 01:08:40 +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
|
||||
{
|
||||
/**
|
||||
* 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<string, bool> 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<string, bool> 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<string, bool> Returns the validation array of the request
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateQACategoryCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
return ['Navigation' => [
|
||||
'Badges' => 'Badges',
|
||||
'QA' => 'QA',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
return ['QA' => [
|
||||
'Badges' => 'Badges',
|
||||
'List' => 'List',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
$tag = $this->getData('tag');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
$tags = $this->getData('tags');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user