These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace SixtyEightPublishers\Application; |
||
6 | |||
7 | class Environment |
||
8 | { |
||
9 | /** @var \SixtyEightPublishers\Application\IProfileStorage */ |
||
10 | private $profileStorage; |
||
11 | |||
12 | /** |
||
13 | * @param \SixtyEightPublishers\Application\ProfileContainer $profileContainer |
||
14 | * @param \SixtyEightPublishers\Application\IEnvironmentDetector $detector |
||
15 | * @param \SixtyEightPublishers\Application\IProfileStorage $profileStorage |
||
16 | */ |
||
17 | public function __construct(ProfileContainer $profileContainer, IEnvironmentDetector $detector, IProfileStorage $profileStorage) |
||
18 | { |
||
19 | $profile = $detector->detect($profileContainer); |
||
20 | $this->profileStorage = $profileStorage; |
||
21 | $this->profileStorage->setProfile($profile instanceof Profile ? $profile : $profileContainer->getDefaultProfile()); |
||
0 ignored issues
–
show
|
|||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @return \SixtyEightPublishers\Application\ActiveProfile |
||
26 | */ |
||
27 | public function getProfile() |
||
28 | { |
||
29 | return $this->profileStorage->getProfile(); |
||
30 | } |
||
31 | } |
||
32 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: