|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Spacecraft\Lib; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
6
|
|
|
use Doctrine\Common\Collections\Collection; |
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
|
9
|
|
|
use Stu\Orm\Entity\ShipInterface; |
|
10
|
|
|
use Stu\Orm\Entity\SpacecraftInterface; |
|
11
|
|
|
use Stu\Orm\Entity\UserInterface; |
|
12
|
|
|
|
|
13
|
|
|
class SpacecraftGroup implements SpacecraftGroupInterface |
|
14
|
|
|
{ |
|
15
|
|
|
/** @var Collection<int, SpacecraftWrapperInterface> */ |
|
16
|
|
|
private Collection $spacecraftWrappers; |
|
17
|
|
|
|
|
18
|
3 |
|
public function __construct( |
|
19
|
|
|
private String $name, |
|
20
|
|
|
private ?UserInterface $user |
|
21
|
|
|
) { |
|
22
|
3 |
|
$this->spacecraftWrappers = new ArrayCollection(); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
3 |
|
#[Override] |
|
26
|
|
|
public function addSpacecraftWrapper(SpacecraftWrapperInterface $wrapper): void |
|
27
|
|
|
{ |
|
28
|
3 |
|
$this->spacecraftWrappers->add($wrapper); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
3 |
|
#[Override] |
|
32
|
|
|
public function getWrappers(): Collection |
|
33
|
|
|
{ |
|
34
|
3 |
|
return $this->spacecraftWrappers; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
3 |
|
#[Override] |
|
38
|
|
|
public function getName(): string |
|
39
|
|
|
{ |
|
40
|
3 |
|
return $this->name; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
3 |
|
#[Override] |
|
44
|
|
|
public function getUser(): ?UserInterface |
|
45
|
|
|
{ |
|
46
|
3 |
|
return $this->user; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param Collection<int, covariant SpacecraftInterface> $spacecrafts |
|
|
|
|
|
|
51
|
|
|
* |
|
52
|
|
|
* @return Collection<int, SpacecraftInterface> |
|
53
|
|
|
*/ |
|
54
|
3 |
|
public static function sortSpacecraftCollection(Collection $spacecrafts): Collection |
|
55
|
|
|
{ |
|
56
|
3 |
|
$spacecraftArray = $spacecrafts->toArray(); |
|
57
|
|
|
|
|
58
|
3 |
|
usort( |
|
59
|
3 |
|
$spacecraftArray, |
|
60
|
3 |
|
function (SpacecraftInterface $a, SpacecraftInterface $b): int { |
|
61
|
2 |
|
$fleetA = $a instanceof ShipInterface ? $a->getFleet() : null; |
|
62
|
2 |
|
$fleetB = $b instanceof ShipInterface ? $b->getFleet() : null; |
|
63
|
|
|
|
|
64
|
2 |
|
$fleetASort = $fleetA !== null ? $fleetA->getSort() : 0; |
|
65
|
2 |
|
$fleetBSort = $fleetB !== null ? $fleetB->getSort() : 0; |
|
66
|
2 |
|
if ($fleetBSort === $fleetASort) { |
|
67
|
1 |
|
$fleetAid = $fleetA !== null ? $fleetA->getId() : 0; |
|
68
|
1 |
|
$fleetBid = $fleetB !== null ? $fleetB->getId() : 0; |
|
69
|
1 |
|
if ($fleetBid === $fleetAid) { |
|
70
|
1 |
|
$aIsFleetLeader = $a instanceof ShipInterface ? $a->isFleetLeader() : false; |
|
71
|
1 |
|
$bIsFleetLeader = $b instanceof ShipInterface ? $b->isFleetLeader() : false; |
|
72
|
1 |
|
if ($bIsFleetLeader === $aIsFleetLeader) { |
|
73
|
1 |
|
$catA = $a->getRump()->getCategoryId(); |
|
74
|
1 |
|
$catB = $b->getRump()->getCategoryId(); |
|
75
|
1 |
|
if ($catB === $catA) { |
|
76
|
1 |
|
$roleA = $a->getRump()->getRoleId(); |
|
77
|
1 |
|
$roleB = $b->getRump()->getRoleId(); |
|
78
|
1 |
|
if ($roleB === $roleA) { |
|
79
|
1 |
|
if ($b->getRumpId() === $a->getRumpId()) { |
|
80
|
1 |
|
return $a->getName() <=> $b->getName(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
return $b->getRumpId() <=> $a->getRumpId(); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
return $roleB <=> $roleA; |
|
87
|
|
|
} |
|
88
|
|
|
return $catB <=> $catA; |
|
89
|
|
|
} |
|
90
|
1 |
|
return $bIsFleetLeader <=> $aIsFleetLeader; |
|
91
|
|
|
} |
|
92
|
|
|
return $fleetBid <=> $fleetAid; |
|
93
|
|
|
} |
|
94
|
2 |
|
return $fleetBSort <=> $fleetASort; |
|
95
|
3 |
|
} |
|
96
|
3 |
|
); |
|
97
|
|
|
|
|
98
|
3 |
|
return new ArrayCollection($spacecraftArray); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths