1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Prestige\Lib; |
6
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
8
|
|
|
use Stu\Lib\Component\ComponentRegistrationInterface; |
9
|
|
|
use Stu\Module\Game\Component\GameComponentEnum; |
10
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
|
|
|
|
11
|
|
|
use Stu\Orm\Entity\DatabaseEntryInterface; |
12
|
|
|
use Stu\Orm\Entity\UserInterface; |
13
|
|
|
use Stu\Orm\Repository\PrestigeLogRepositoryInterface; |
14
|
|
|
use Stu\Orm\Repository\UserRepositoryInterface; |
15
|
|
|
|
16
|
|
|
final class CreatePrestigeLog implements CreatePrestigeLogInterface |
17
|
|
|
{ |
18
|
2 |
|
public function __construct( |
19
|
|
|
private PrestigeLogRepositoryInterface $prestigeLogRepository, |
20
|
|
|
private UserRepositoryInterface $userRepository, |
21
|
|
|
private ComponentRegistrationInterface $componentRegistration |
22
|
2 |
|
) {} |
23
|
|
|
|
24
|
|
|
#[Override] |
25
|
|
|
public function createLog(int $amount, string $description, UserInterface $user, int $date): void |
26
|
|
|
{ |
27
|
|
|
$this->createLogIntern($amount, $description, $user, $date); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
#[Override] |
31
|
|
|
public function createLogForDatabaseEntry(DatabaseEntryInterface $databaseEntry, UserInterface $user, int $date): void |
32
|
|
|
{ |
33
|
|
|
$amount = $databaseEntry->getCategory()->getPrestige(); |
34
|
|
|
$description = sprintf( |
35
|
|
|
'%d Prestige erhalten für die Entdeckung von "%s" in der Kategorie "%s"', |
36
|
|
|
$amount, |
37
|
|
|
$databaseEntry->getDescription(), |
38
|
|
|
$databaseEntry->getCategory()->getDescription() |
39
|
|
|
); |
40
|
|
|
|
41
|
|
|
$this->createLogIntern($amount, $description, $user, $date); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
private function createLogIntern(int $amount, string $description, UserInterface $user, int $date): void |
45
|
|
|
{ |
46
|
|
|
if ($user->getId() < UserEnum::USER_FIRST_ID) { |
47
|
|
|
return; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$prestigeLog = $this->prestigeLogRepository->prototype(); |
51
|
|
|
$prestigeLog->setUserId($user->getId()); |
52
|
|
|
$prestigeLog->setAmount($amount); |
53
|
|
|
$prestigeLog->setDate($date); |
54
|
|
|
$prestigeLog->setDescription($description); |
55
|
|
|
|
56
|
|
|
$this->prestigeLogRepository->save($prestigeLog); |
57
|
|
|
|
58
|
|
|
//update user prestige |
59
|
|
|
$user->setPrestige($user->getPrestige() + $prestigeLog->getAmount()); |
60
|
|
|
$this->userRepository->save($user); |
61
|
|
|
|
62
|
|
|
$this->componentRegistration->addComponentUpdate(GameComponentEnum::USER); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
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