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

@ -142,7 +142,7 @@ class PollController extends EmailsController {
return $this->notFoundPoll( $customUrl );
}
if ( md5($poll->getPassword()) === $md5 ) {
if ( md5( $poll->getPassword() ) === $md5 ) {
// good matching pass
return $this->json( $poll->display() );
} else {

View File

@ -71,7 +71,7 @@ class VoteController extends EmailsController {
$stack = new StackOfVotes();
$stack
->setOwner( $foundOwner )
->setIp($_SERVER['REMOTE_ADDR'])
->setIp( $_SERVER[ 'REMOTE_ADDR' ] )
->setPseudo( $data[ 'pseudo' ] )
->setPoll( $poll );
foreach ( $data[ 'votes' ] as $voteInfo ) {

View File

@ -53,7 +53,7 @@ class Choice {
private $poll;
public function __construct( $optionalName = null ) {
$this->setCreatedAt( new DateTime());
$this->setCreatedAt( new DateTime() );
$this->poll = new ArrayCollection();
$this->votes = new ArrayCollection();
$this->setDateTime( new DateTime() );

View File

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

View File

@ -66,7 +66,7 @@ class Owner {
$this->stackOfVotes = new ArrayCollection();
$this->setCreatedAt( new DateTime() );
$this->setModifierToken( uniqid() );
$this->setCreatedAt( new DateTime());
$this->setCreatedAt( new DateTime() );
}
public function setCreatedAt( DateTimeInterface $createdAt ): self {
@ -75,6 +75,10 @@ class Owner {
return $this;
}
public function getCreatedAt(): ?DateTimeInterface {
return $this->createdAt;
}
public function display() {
return [
'pseudo' => $this->getPseudo(),
@ -228,10 +232,6 @@ class Owner {
return $this;
}
public function getCreatedAt(): ?DateTimeInterface {
return $this->createdAt;
}
public function getRequestedPollsDate() {
return $this->requestedPollsDate;
}

View File

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

View File

@ -53,7 +53,7 @@ class Vote {
private $stacksOfVotes;
public function __construct() {
$this->setCreatedAt( new DateTime());
$this->setCreatedAt( new DateTime() );
}
public function display() {

View File

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