cleanup and tests added for ci/cd

This commit is contained in:
Dennis Eichhorn 2019-11-20 22:28:04 +01:00
parent 17ee679457
commit 798667365e
3 changed files with 204 additions and 7 deletions

View File

@ -66,41 +66,105 @@ class QAAnswer implements \JsonSerializable
return $this->id; return $this->id;
} }
/**
* Get the answer
*
* @return string
*
* @since 1.0.0
*/
public function getAnswer() : string public function getAnswer() : string
{ {
return $this->answer; return $this->answer;
} }
/**
* Set the answer
*
* @param string $answer Answer
*
* @return void
*
* @since 1.0.0
*/
public function setAnswer(string $answer) : void public function setAnswer(string $answer) : void
{ {
$this->answer = $answer; $this->answer = $answer;
} }
/**
* Get the question
*
* @return int
*
* @since 1.0.0
*/
public function getQuestion() : int public function getQuestion() : int
{ {
return $this->question; return $this->question;
} }
/**
* Set the question
*
* @param int $question Question
*
* @return void
*
* @since 1.0.0
*/
public function setQuestion(int $question) : void public function setQuestion(int $question) : void
{ {
$this->question = $question; $this->question = $question;
} }
/**
* Get the status
*
* @return int
*
* @since 1.0.0
*/
public function getStatus() : int public function getStatus() : int
{ {
return $this->status; return $this->status;
} }
/**
* Set the status
*
* @param int $status Status
*
* @return void
*
* @since 1.0.0
*/
public function setStatus(int $status) : void public function setStatus(int $status) : void
{ {
$this->status = $status; $this->status = $status;
} }
/**
* Set the answer as accepted
*
* @param bool $accepted Accepted
*
* @return void
*
* @since 1.0.0
*/
public function setAccepted(bool $accepted) : void public function setAccepted(bool $accepted) : void
{ {
$this->isAccepted = $accepted; $this->isAccepted = $accepted;
} }
/**
* Is the answer accepted
*
* @return bool
*
* @since 1.0.0
*/
public function isAccepted() : bool public function isAccepted() : bool
{ {
return $this->isAccepted; return $this->isAccepted;
@ -118,13 +182,22 @@ class QAAnswer implements \JsonSerializable
return $this->createdBy; return $this->createdBy;
} }
/**
* Set created by
*
* @param mixed $id Creator
*
* @return void
*
* @since 1.0.0
*/
public function setCreatedBy($id) : void public function setCreatedBy($id) : void
{ {
$this->createdBy = $id; $this->createdBy = $id;
} }
/** /**
* Get created at date time * Get created at
* *
* @return \DateTime * @return \DateTime
* *

View File

@ -80,11 +80,27 @@ class QACategory implements \JsonSerializable
$this->name = $name; $this->name = $name;
} }
/**
* Get the parent category
*
* @return null|int
*
* @since 1.0.0
*/
public function getParent() : ?int public function getParent() : ?int
{ {
return $this->parent; return $this->parent;
} }
/**
* Set the parent category
*
* @param int $parent Parent category
*
* @return void
*
* @since 1.0.0
*/
public function setParent(int $parent) : void public function setParent(int $parent) : void
{ {
$this->parent = $parent; $this->parent = $parent;

View File

@ -33,17 +33,35 @@ class QAQuestion implements \JsonSerializable
protected int $id = 0; protected int $id = 0;
/** /**
* Name. * Title.
* *
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $name = ''; private string $name = '';
/**
* Question status.
*
* @var int
* @since 1.0.0
*/
private int $status = QAQuestionStatus::ACTIVE; private int $status = QAQuestionStatus::ACTIVE;
private $question = ''; /**
* Question.
*
* @var string
* @since 1.0.0
*/
private string $question = '';
/**
* Category.
*
* @var int
* @since 1.0.0
*/
private $category = 0; private $category = 0;
private $language = ''; private $language = '';
@ -52,9 +70,21 @@ class QAQuestion implements \JsonSerializable
private $createdAt = null; private $createdAt = null;
private $badges = []; /**
* Badges.
*
* @var array
* @since 1.0.0
*/
private array $badges = [];
private $answers = []; /**
* Answers.
*
* @var array
* @since 1.0.0
*/
private array $answers = [];
/** /**
* Constructor. * Constructor.
@ -78,6 +108,13 @@ class QAQuestion implements \JsonSerializable
return $this->id; return $this->id;
} }
/**
* Does the question have a accepted answer?
*
* @return bool
*
* @since 1.0.0
*/
public function hasAccepted() : bool public function hasAccepted() : bool
{ {
foreach ($this->answers as $answer) { foreach ($this->answers as $answer) {
@ -89,16 +126,39 @@ class QAQuestion implements \JsonSerializable
return false; return false;
} }
/**
* Get the language
*
* @return string
*
* @since 1.0.0
*/
public function getLanguage() : string public function getLanguage() : string
{ {
return $this->language; return $this->language;
} }
/**
* Set the language
*
* @param string $language Language
*
* @return void
*
* @since 1.0.0
*/
public function setLanguage(string $language) : void public function setLanguage(string $language) : void
{ {
$this->language = $language; $this->language = $language;
} }
/**
* Is the question answered?
*
* @return bool
*
* @since 1.0.0
*/
public function isAnswered() : bool public function isAnswered() : bool
{ {
foreach ($this->answers as $answer) { foreach ($this->answers as $answer) {
@ -111,7 +171,7 @@ class QAQuestion implements \JsonSerializable
} }
/** /**
* Get name * Get title.
* *
* @return string * @return string
* *
@ -123,7 +183,7 @@ class QAQuestion implements \JsonSerializable
} }
/** /**
* Set name * Set name.
* *
* @param string $name Name * @param string $name Name
* *
@ -136,31 +196,79 @@ class QAQuestion implements \JsonSerializable
$this->name = $name; $this->name = $name;
} }
/**
* Get the question.
*
* @return string
*
* @since 1.0.0
*/
public function getQuestion() : string public function getQuestion() : string
{ {
return $this->question; return $this->question;
} }
/**
* Set the question
*
* @param string $question Question
*
* @return void
*
* @since 1.0.0
*/
public function setQuestion(string $question) : void public function setQuestion(string $question) : void
{ {
$this->question = $question; $this->question = $question;
} }
/**
* Get the status
*
* @return int
*
* @since 1.0.0
*/
public function getStatus() : int public function getStatus() : int
{ {
return $this->status; return $this->status;
} }
/**
* Set the status
*
* @param int $status Status
*
* @return void
*
* @since 1.0.0
*/
public function setStatus(int $status) : void public function setStatus(int $status) : void
{ {
$this->status = $status; $this->status = $status;
} }
/**
* Get the category
*
* @return mixed
*
* @since 1.0.0
*/
public function getCategory() public function getCategory()
{ {
return $this->category; return $this->category;
} }
/**
* Set the category
*
* @param int $category Category
*
* @return void
*
* @since 1.0.0
*/
public function setCategory(int $category) : void public function setCategory(int $category) : void
{ {
$this->category = $category; $this->category = $category;