This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace PlaygroundGame\Service; |
||
4 | |||
5 | use Zend\ServiceManager\ServiceManager; |
||
6 | use PlaygroundGame\Service\Game; |
||
7 | use PlaygroundGame\Entity\MissionGameCondition as MissionGameConditionEntity; |
||
8 | |||
9 | class Mission extends Game |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * @var MissionMapperInterface |
||
14 | */ |
||
15 | protected $missionMapper; |
||
16 | |||
17 | /** |
||
18 | * @var MissionGameMapperInterface |
||
19 | */ |
||
20 | protected $missionGameMapper; |
||
21 | |||
22 | protected $options; |
||
23 | |||
24 | /** |
||
25 | * Find games associated to a mission and add the last entry of the user if it exists |
||
26 | * @param unknown $mission |
||
27 | * @return multitype:NULL |
||
0 ignored issues
–
show
|
|||
28 | */ |
||
29 | public function getMissionGames($mission, $user) |
||
30 | { |
||
31 | $games = array(); |
||
32 | $missionGames = $this->findGamesByMission($mission); |
||
33 | foreach ($missionGames as $missionGame) { |
||
34 | $entry = $this->checkExistingEntry($missionGame->getGame(), $user); |
||
35 | $games[$missionGame->getGame()->getIdentifier()]['game'] = $missionGame; |
||
36 | $games[$missionGame->getGame()->getIdentifier()]['entry'] = $entry; |
||
37 | } |
||
38 | |||
39 | return $games; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * findMissionGameByMission : find associated games to a mission |
||
44 | * @param Mission $mission |
||
45 | * |
||
46 | * @return Collection de MissionGame $missionGames |
||
47 | */ |
||
48 | public function findGamesByMission($mission) |
||
49 | { |
||
50 | return $this->getMissionGameMapper()->findBy(array('mission'=>$mission)); |
||
51 | } |
||
52 | |||
53 | View Code Duplication | public function checkMissionCondition($game, $winner, $prediction, $entry) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
54 | { |
||
55 | $missionGame = $this->findMissionGameByGame($game); |
||
0 ignored issues
–
show
The method
findMissionGameByGame() does not seem to exist on object<PlaygroundGame\Service\Mission> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
56 | if (empty($missionGame)) { |
||
57 | return false; |
||
58 | } |
||
59 | |||
60 | if ($missionGame->getMission()->getActive() === false) { |
||
61 | return false; |
||
62 | } |
||
63 | |||
64 | $nextMissionGame = $this->getMissionGameMapper()->getNextGame( |
||
65 | $missionGame->getMission(), |
||
66 | $missionGame->getPosition() |
||
67 | ); |
||
68 | |||
69 | if (empty($nextMissionGame)) { |
||
70 | return false; |
||
71 | } |
||
72 | |||
73 | $missionGameConditions = $this->findMissionGameConditionByMissionGame($nextMissionGame); |
||
0 ignored issues
–
show
The method
findMissionGameConditionByMissionGame() does not seem to exist on object<PlaygroundGame\Service\Mission> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
74 | |||
75 | if (empty($missionGameConditions)) { |
||
76 | return false; |
||
77 | } |
||
78 | |||
79 | foreach ($missionGameConditions as $missionGameCondition) { |
||
80 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::NONE) { |
||
81 | continue; |
||
82 | } |
||
83 | |||
84 | // On passe au suivant si on a gagné |
||
85 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::VICTORY) { |
||
86 | if (!($winner || $prediction)) { |
||
87 | return false; |
||
88 | } |
||
89 | } |
||
90 | |||
91 | // On passe au suivant si on a perdu |
||
92 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::DEFEAT) { |
||
93 | if ($winner || $prediction) { |
||
94 | return false; |
||
95 | } |
||
96 | } |
||
97 | |||
98 | // On passe au suivant si on a perdu |
||
99 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::GREATER) { |
||
100 | if (!$entry) { |
||
101 | return false; |
||
102 | } |
||
103 | if (!($entry->getPoints() > $missionGameCondition->getValue())) { |
||
104 | return false; |
||
105 | } |
||
106 | } |
||
107 | |||
108 | // On passe au suivant si on a perdu |
||
109 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::LESS) { |
||
110 | if (!$entry) { |
||
111 | return false; |
||
112 | } |
||
113 | if (!($entry->getPoints() < $missionGameCondition->getValue())) { |
||
114 | return false; |
||
115 | } |
||
116 | } |
||
117 | } |
||
118 | |||
119 | return $nextMissionGame->getGame(); |
||
120 | } |
||
121 | |||
122 | public function getGameEntity() |
||
123 | { |
||
124 | return new \PlaygroundGame\Entity\Mission; |
||
125 | } |
||
126 | |||
127 | /** |
||
128 | * getMissionMapper |
||
129 | * |
||
130 | * @return MissionMapperInterface |
||
131 | */ |
||
132 | public function getMissionMapper() |
||
133 | { |
||
134 | if (null === $this->missionMapper) { |
||
135 | $this->missionMapper = $this->serviceLocator->get('playgroundgame_mission_mapper'); |
||
136 | } |
||
137 | |||
138 | return $this->missionMapper; |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * setMissionMapper |
||
143 | * |
||
144 | * @param MissionMapperInterface $missionMapper |
||
145 | * @return Mission |
||
146 | */ |
||
147 | public function setMissionMapper($missionMapper) |
||
148 | { |
||
149 | $this->missionMapper = $missionMapper; |
||
150 | |||
151 | return $this; |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * getMissionGameMapper |
||
156 | * |
||
157 | * @return MissionGameMapperInterface |
||
158 | */ |
||
159 | View Code Duplication | public function getMissionGameMapper() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
160 | { |
||
161 | if (null === $this->missionGameMapper) { |
||
162 | $this->missionGameMapper = $this->serviceLocator->get('playgroundgame_mission_game_mapper'); |
||
163 | } |
||
164 | |||
165 | return $this->missionGameMapper; |
||
166 | } |
||
167 | |||
168 | /** |
||
169 | * setMissionMapper |
||
170 | * |
||
171 | * @param MissionMapperInterface $missionGameMapper |
||
172 | * @return Mission |
||
173 | */ |
||
174 | public function setMissionGameMapper($missionGameMapper) |
||
175 | { |
||
176 | $this->missionGameMapper = $missionGameMapper; |
||
0 ignored issues
–
show
It seems like
$missionGameMapper of type object<PlaygroundGame\Se...MissionMapperInterface> is incompatible with the declared type object<PlaygroundGame\Se...ionGameMapperInterface> of property $missionGameMapper .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
177 | |||
178 | return $this; |
||
179 | } |
||
180 | } |
||
181 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.