|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Trade\Lib; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use Stu\Orm\Entity\ShipInterface; |
|
9
|
|
|
use Stu\Orm\Entity\StorageInterface; |
|
10
|
|
|
use Stu\Orm\Entity\TradePostInterface; |
|
11
|
|
|
use Stu\Orm\Repository\StorageRepositoryInterface; |
|
12
|
|
|
|
|
13
|
|
|
final class DealAccountWrapper implements DealAccountWrapperInterface |
|
14
|
|
|
{ |
|
15
|
|
|
/** @var array<StorageInterface> */ |
|
16
|
|
|
private ?array $storage = null; |
|
17
|
|
|
|
|
18
|
|
|
public function __construct( |
|
19
|
|
|
private StorageRepositoryInterface $storageRepository, |
|
20
|
|
|
private TradePostInterface $tradePost, |
|
21
|
|
|
private int $userId |
|
22
|
|
|
) { |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
#[Override] |
|
26
|
|
|
public function getId(): int |
|
27
|
|
|
{ |
|
28
|
|
|
return $this->tradePost->getId(); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
#[Override] |
|
32
|
|
|
public function getShip(): ShipInterface |
|
33
|
|
|
{ |
|
34
|
|
|
return $this->tradePost->getShip(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** @return array<StorageInterface> */ |
|
38
|
|
|
private function getStorage(): array |
|
39
|
|
|
{ |
|
40
|
|
|
if ($this->storage === null) { |
|
41
|
|
|
$this->storage = $this->storageRepository->getByTradePostAndUser( |
|
42
|
|
|
$this->tradePost->getId(), |
|
43
|
|
|
$this->userId |
|
44
|
|
|
); |
|
45
|
|
|
} |
|
46
|
|
|
return $this->storage; |
|
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
#[Override] |
|
50
|
|
|
public function getStorageSum(): int |
|
51
|
|
|
{ |
|
52
|
|
|
return array_reduce( |
|
53
|
|
|
$this->getStorage(), |
|
54
|
|
|
fn (int $value, StorageInterface $storage): int => $value + $storage->getAmount(), |
|
55
|
|
|
0 |
|
56
|
|
|
); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
#[Override] |
|
60
|
|
|
public function isOverStorage(): bool |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->getStorageSum() > $this->tradePost->getStorage(); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
#[Override] |
|
66
|
|
|
public function getStorageCapacity(): int |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->tradePost->getStorage(); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
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