You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1KB

  1. <?php
  2. namespace Lc\PietroBundle\Solver\Workshop;
  3. use Lc\PietroBundle\Model\Workshop\WorkshopInterface;
  4. class WorkshopSolver
  5. {
  6. public function countEntriesAnimators(WorkshopInterface $workshop): int
  7. {
  8. return count($this->getEntriesByIsAnimator($workshop, true));
  9. }
  10. public function countEntriesRegistered(WorkshopInterface $workshop): int
  11. {
  12. return count($this->getEntriesByIsAnimator($workshop, false));
  13. }
  14. public function getEntriesRegistered(WorkshopInterface $workshop)
  15. {
  16. return $this->getEntriesByIsAnimator($workshop, false);
  17. }
  18. public function getEntriesAnimators(WorkshopInterface $workshop)
  19. {
  20. return $this->getEntriesByIsAnimator($workshop, true);
  21. }
  22. public function getEntriesByIsAnimator(WorkshopInterface $workshop, bool $isAnimator): array
  23. {
  24. $entryArray = [];
  25. foreach($workshop->getEntries() as $entry) {
  26. if($entry->isAnimator() == $isAnimator) {
  27. $entryArray[] = $entry;
  28. }
  29. }
  30. return $entryArray;
  31. }
  32. }