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.
1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | /* |
||||
6 | * Copyright (C) 2020-2025 Iain Cambridge |
||||
7 | * |
||||
8 | * This program is free software: you can redistribute it and/or modify |
||||
9 | * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by |
||||
10 | * the Free Software Foundation, either version 2.1 of the License, or |
||||
11 | * (at your option) any later version. |
||||
12 | * |
||||
13 | * This program is distributed in the hope that it will be useful, |
||||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
16 | * GNU Lesser General Public License for more details. |
||||
17 | * |
||||
18 | * You should have received a copy of the GNU General Public License |
||||
19 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
20 | */ |
||||
21 | |||||
22 | namespace Parthenon\Billing\Plan; |
||||
23 | |||||
24 | use BillaBear\Model\Feature; |
||||
0 ignored issues
–
show
|
|||||
25 | use BillaBear\Model\Limit; |
||||
0 ignored issues
–
show
The type
BillaBear\Model\Limit was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
26 | use BillaBear\Model\Price; |
||||
0 ignored issues
–
show
The type
BillaBear\Model\Price was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
27 | use BillaBear\Model\SubscriptionPlan; |
||||
0 ignored issues
–
show
The type
BillaBear\Model\SubscriptionPlan was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
28 | use Doctrine\Common\Collections\Collection; |
||||
29 | use Parthenon\Billing\BillaBear\SdkFactory; |
||||
30 | use Parthenon\Billing\Exception\NoPlanFoundException; |
||||
31 | |||||
32 | final class BillaBearPlanManager implements PlanManagerInterface |
||||
33 | { |
||||
34 | private ?array $plans = null; |
||||
35 | |||||
36 | public function __construct( |
||||
37 | private SdkFactory $sdkFactory, |
||||
38 | ) { |
||||
39 | } |
||||
40 | |||||
41 | public function getPlans(): array |
||||
42 | { |
||||
43 | if (!isset($this->plans)) { |
||||
44 | $data = $this->sdkFactory->createSubscriptionsApi()->listSubscriptionPlans(limit: 100); |
||||
45 | |||||
46 | $output = []; |
||||
47 | foreach ($data->getData() as $planEntity) { |
||||
48 | $output[] = $this->convertPlan($planEntity); |
||||
49 | } |
||||
50 | $this->plans = $output; |
||||
51 | } |
||||
52 | |||||
53 | return $output; |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
54 | } |
||||
55 | |||||
56 | public function getPlanForUser(LimitedUserInterface $limitedUser): Plan |
||||
57 | { |
||||
58 | return $this->getPlanByName($limitedUser->getPlanName()); |
||||
0 ignored issues
–
show
It seems like
$limitedUser->getPlanName() can also be of type null ; however, parameter $planName of Parthenon\Billing\Plan\B...anager::getPlanByName() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
59 | } |
||||
60 | |||||
61 | public function getPlanByName(string $planName): Plan |
||||
62 | { |
||||
63 | $plans = $this->getPlans(); |
||||
64 | |||||
65 | foreach ($plans as $plan) { |
||||
66 | if ($plan->getName() === $planName) { |
||||
67 | return $plan; |
||||
68 | } |
||||
69 | } |
||||
70 | throw new NoPlanFoundException(); |
||||
71 | } |
||||
72 | |||||
73 | protected function convertPlan(SubscriptionPlan $subscriptionPlan): Plan |
||||
74 | { |
||||
75 | return new Plan( |
||||
76 | $subscriptionPlan->getName(), |
||||
77 | $this->convertLimits($subscriptionPlan->getLimits()), |
||||
78 | $this->convertFeatures($subscriptionPlan->getFeatures()), |
||||
79 | $this->convertPrices($subscriptionPlan->getPrices()), |
||||
80 | $subscriptionPlan->getFree(), |
||||
81 | $subscriptionPlan->getPerSeat(), |
||||
82 | $subscriptionPlan->getUserCount(), |
||||
83 | $subscriptionPlan->getPublic(), |
||||
84 | $subscriptionPlan->getHasTrial(), |
||||
85 | $subscriptionPlan->getTrialLengthDays(), |
||||
86 | $subscriptionPlan->getId() |
||||
87 | ); |
||||
88 | } |
||||
89 | |||||
90 | /** |
||||
91 | * @param Limit[] $limits |
||||
92 | */ |
||||
93 | protected function convertLimits(array $limits): array |
||||
94 | { |
||||
95 | $output = []; |
||||
96 | |||||
97 | foreach ($limits as $limit) { |
||||
98 | $output[$limit->getFeature()->getCode()] = [ |
||||
99 | 'name' => $limit->getFeature()->getName(), |
||||
100 | 'code' => $limit->getFeature()->getCode(), |
||||
101 | 'limit' => $limit->getLimit(), |
||||
102 | 'description' => $limit->getFeature()->getDescription(), |
||||
103 | ]; |
||||
104 | } |
||||
105 | |||||
106 | return $output; |
||||
107 | } |
||||
108 | |||||
109 | /** |
||||
110 | * @param Feature[]|Collection $features |
||||
111 | */ |
||||
112 | protected function convertFeatures(array $features): array |
||||
113 | { |
||||
114 | $output = []; |
||||
115 | |||||
116 | foreach ($features as $feature) { |
||||
117 | $output[$feature->getCode()] = [ |
||||
118 | 'code' => $feature->getCode(), |
||||
119 | 'name' => $feature->getName(), |
||||
120 | 'description' => $feature->getDescription(), |
||||
121 | ]; |
||||
122 | } |
||||
123 | |||||
124 | return $output; |
||||
125 | } |
||||
126 | |||||
127 | /** |
||||
128 | * @param Price[]|Collection $prices |
||||
129 | */ |
||||
130 | protected function convertPrices(array $prices): array |
||||
131 | { |
||||
132 | $output = []; |
||||
133 | |||||
134 | foreach ($prices as $price) { |
||||
135 | $schedule = $price->getSchedule(); |
||||
136 | |||||
137 | if (!isset($output[$schedule])) { |
||||
138 | $output[$schedule] = []; |
||||
139 | } |
||||
140 | |||||
141 | $output[$schedule][$price->getCurrency()] = [ |
||||
142 | 'amount' => (string) $price->getAmount(), |
||||
143 | 'currency' => $price->getCurrency(), |
||||
144 | 'price_id' => $price->getExternalReference(), |
||||
145 | 'public' => $price->getPublic(), |
||||
146 | 'entity_id' => $price->getId(), |
||||
147 | ]; |
||||
148 | } |
||||
149 | |||||
150 | return $output; |
||||
151 | } |
||||
152 | } |
||||
153 |
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