From 08f7ca141d3f7f054dccba1e86b9f4d94f316e82 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 6 Apr 2018 09:43:32 +0200 Subject: [PATCH] CS Signed-off-by: Thomas Citharel --- .../Framadate/Services/PollService.php | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/app/classes/Framadate/Services/PollService.php b/app/classes/Framadate/Services/PollService.php index a01e683..ad180b1 100644 --- a/app/classes/Framadate/Services/PollService.php +++ b/app/classes/Framadate/Services/PollService.php @@ -177,46 +177,12 @@ class PollService { return $this->pollRepository->findAllByAdminMail($mail); } - /** - * @param \stdClass $poll - * @return array - */ - private function computeEmptyBestChoices($poll) - { - $result = ['y' => [], 'inb' => []]; - // if there is no votes, calculates the number of slot - - $slots = $this->allSlotsByPoll($poll); - - if ($poll->format === 'A') { - // poll format classic - - for ($i = 0; $i < count($slots); $i++) { - $result['y'][] = 0; - $result['inb'][] = 0; - } - } else { - // poll format date - - $slots = $this->splitSlots($slots); - - foreach ($slots as $slot) { - for ($i = 0; $i < count($slot->moments); $i++) { - $result['y'][] = 0; - $result['inb'][] = 0; - } - } - } - return $result; - } - /** * @param array $votes * @param \stdClass $poll * @return array */ public function computeBestChoices($votes, $poll) { - if (0 === count($votes)) { return $this->computeEmptyBestChoices($poll); } @@ -305,6 +271,39 @@ class PollService { return $slots; } + /** + * @param \stdClass $poll + * @return array + */ + private function computeEmptyBestChoices($poll) + { + $result = ['y' => [], 'inb' => []]; + // if there is no votes, calculates the number of slot + + $slots = $this->allSlotsByPoll($poll); + + if ($poll->format === 'A') { + // poll format classic + + for ($i = 0; $i < count($slots); $i++) { + $result['y'][] = 0; + $result['inb'][] = 0; + } + } else { + // poll format date + + $slots = $this->splitSlots($slots); + + foreach ($slots as $slot) { + for ($i = 0; $i < count($slot->moments); $i++) { + $result['y'][] = 0; + $result['inb'][] = 0; + } + } + } + return $result; + } + private function random($length) { return Token::getToken($length); }