1 | <?php |
||
20 | class EntityComparerByTimeStartTimeAndLocalIdentifier implements EntityComparerInterface |
||
21 | { |
||
22 | //<editor-fold desc="Fields"> |
||
23 | /** @var TimeServiceInterface */ |
||
24 | private $timeService; |
||
25 | //</editor-fold desc="Fields"> |
||
26 | |||
27 | //<editor-fold desc="Constructor"> |
||
28 | /** |
||
29 | * EntityComparerByTimeStartTimeAndLocalIdentifier constructor. |
||
30 | * @param TimeServiceInterface $timeService |
||
31 | */ |
||
32 | public function __construct(TimeServiceInterface $timeService) |
||
36 | //</editor-fold desc="Constructor"> |
||
37 | |||
38 | |||
39 | //<editor-fold desc="Public Methods"> |
||
40 | /** |
||
41 | * @inheritDoc |
||
42 | */ |
||
43 | public function compareEntities(TournamentHierarchyInterface $entity1, TournamentHierarchyInterface $entity2): int |
||
58 | //</editor-fold desc="Public Methods"> |
||
59 | |||
60 | //<editor-fold desc="Protected Methods"> |
||
61 | /** |
||
62 | * Compares the times of the two entities using the time array and using their start times |
||
63 | * @param TournamentHierarchyInterface $entity1 the first entity to compare |
||
64 | * @param TournamentHierarchyInterface $entity2 the second entity to compare |
||
65 | * @return int returns -1 if the relevant times of entity1 are before the relevant times of entity2, 1 if the times of |
||
66 | * entity2 are before the times of entity1 and 0 if they have the same times |
||
67 | */ |
||
68 | protected function compareEntityTimes(TournamentHierarchyInterface $entity1, |
||
87 | |||
88 | /** |
||
89 | * Compares the local identifiers of the predecessors of the given entities, beginning from the tournament level |
||
90 | * @param TournamentHierarchyInterface $entity1 the first entity to compare |
||
91 | * @param TournamentHierarchyInterface $entity2 the second entity to compare |
||
92 | * @return int returns -1 if the first predecessor with a lower local identifier is of entity1, 1 if it is of entity2 |
||
93 | * and 0 if the two entities are equal (<=> all predecessors have same local identifiers) |
||
94 | */ |
||
95 | protected function compareLocalIdentifiersWithinTournament(TournamentHierarchyInterface $entity1, |
||
111 | //</editor-fold desc="Protected Methods"> |
||
112 | |||
113 | //<editor-fold desc="Private Methods"> |
||
114 | /** |
||
115 | * Gets a list of all predecessors of the given entity $entity (inclusive $entity itself). |
||
116 | * @param TournamentHierarchyInterface $entity the entity for which to get the predecessors |
||
117 | * @return TournamentHierarchyInterface[] the predecessors of $entity inclusive $entity |
||
118 | */ |
||
119 | private function getPredecessors(TournamentHierarchyInterface $entity): array |
||
128 | //</editor-fold desc="Private Methods"> |
||
129 | } |