cleanup src

This commit is contained in:
Tykayn 2021-04-27 12:51:21 +02:00 committed by tykayn
parent 94c02be927
commit 4bf2625908
8 changed files with 40 additions and 39 deletions

View File

@ -59,6 +59,10 @@ class Comment {
return $this; return $this;
} }
public function getCreatedAt(): ?DateTimeInterface {
return $this->createdAt;
}
function display() { function display() {
return [ return [
'id' => $this->getId(), 'id' => $this->getId(),
@ -92,10 +96,6 @@ class Comment {
return $this; return $this;
} }
public function getCreatedAt(): ?DateTimeInterface {
return $this->createdAt;
}
public function getPoll(): ?Poll { public function getPoll(): ?Poll {
return $this->poll; return $this->poll;
} }

View File

@ -75,6 +75,10 @@ class Owner {
return $this; return $this;
} }
public function getCreatedAt(): ?DateTimeInterface {
return $this->createdAt;
}
public function display() { public function display() {
return [ return [
'pseudo' => $this->getPseudo(), 'pseudo' => $this->getPseudo(),
@ -228,10 +232,6 @@ class Owner {
return $this; return $this;
} }
public function getCreatedAt(): ?DateTimeInterface {
return $this->createdAt;
}
public function getRequestedPollsDate() { public function getRequestedPollsDate() {
return $this->requestedPollsDate; return $this->requestedPollsDate;
} }

View File

@ -216,6 +216,11 @@ class Poll {
$this->setAllowedAnswers( [ 'yes', 'maybe', 'no' ] ); $this->setAllowedAnswers( [ 'yes', 'maybe', 'no' ] );
} }
public function setCreatedAt( DateTimeInterface $createdAt ): self {
$this->createdAt = $createdAt;
return $this;
}
public function displayForAdmin() { public function displayForAdmin() {
$content = $this->display(); $content = $this->display();
@ -227,6 +232,8 @@ class Poll {
return $content; return $content;
} }
// counts each number of answer for this choice
public function display() { public function display() {
$computedAnswers = $this->computeAnswers(); $computedAnswers = $this->computeAnswers();
@ -269,7 +276,6 @@ class Poll {
]; ];
} }
// counts each number of answer for this choice
public function computeAnswers() { public function computeAnswers() {
$computedArray = []; $computedArray = [];
$maxScore = 0; $maxScore = 0;
@ -334,6 +340,23 @@ class Poll {
]; ];
} }
/**
* @return Collection|Choice[]
*/
public function getChoices(): Collection {
return $this->choices;
}
public function getKind(): ?string {
return $this->kind;
}
public function setKind( string $kind ): self {
$this->kind = $kind;
return $this;
}
public function getStacksOfVotes() { public function getStacksOfVotes() {
return $this->stacksOfVotes; return $this->stacksOfVotes;
} }
@ -344,13 +367,6 @@ class Poll {
return $this; return $this;
} }
/**
* @return Collection|Choice[]
*/
public function getChoices(): Collection {
return $this->choices;
}
/** /**
* @return Collection|Comment[] * @return Collection|Comment[]
*/ */
@ -382,12 +398,6 @@ class Poll {
return $this->createdAt; return $this->createdAt;
} }
public function setCreatedAt( DateTimeInterface $createdAt ): self {
$this->createdAt = $createdAt;
return $this;
}
public function getExpiracyDate(): ?DateTimeInterface { public function getExpiracyDate(): ?DateTimeInterface {
return $this->expiracyDate; return $this->expiracyDate;
} }
@ -418,16 +428,6 @@ class Poll {
return $this; return $this;
} }
public function getKind(): ?string {
return $this->kind;
}
public function setKind( string $kind ): self {
$this->kind = $kind;
return $this;
}
public function getAllowedAnswers(): ?array { public function getAllowedAnswers(): ?array {
return $this->allowedAnswers; return $this->allowedAnswers;
} }

View File

@ -2,6 +2,7 @@
namespace App\Traits; namespace App\Traits;
use DateInterval;
use DateTime; use DateTime;
use DateTimeInterface; use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -29,7 +30,7 @@ trait TimeStampableTrait {
public function addDaysToDate( DateTime $date, int $days ) { public function addDaysToDate( DateTime $date, int $days ) {
return $date->add(new \DateInterval('P'.$days.'D')); return $date->add( new DateInterval( 'P' . $days . 'D' ) );
} }