Issues (222)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Billing/Plan/Plan.php (1 issue)

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 Parthenon\Billing\Exception\NoPlanPriceFoundException;
25
use Parthenon\Common\Exception\ParameterNotSetException;
26
27
final class Plan implements PlanInterface
28
{
29
    public const PAY_YEARLY = 'yearly';
30
    public const PAY_MONTHLY = 'monthly';
31
    public const CHECK_FEATURE = 'feature';
32
33
    public function __construct(
34
        private string $name,
35
        private array $limits,
36
        private array $features,
37
        private array $prices,
38
        private bool $isFree,
39
        private bool $isPerSeat,
40
        private int $userCount,
41
        private bool $public = false,
42
        private ?bool $hasTrial = false,
43
        private ?int $trialLengthDays = 0,
44
        private mixed $entityId = null,
45
    ) {
46
    }
47
48
    public function getName(): string
49
    {
50
        return $this->name;
51
    }
52
53
    public function hasFeature(string $featureName): bool
54
    {
55
        return in_array($featureName, $this->features);
56
    }
57
58
    public function getLimit(LimitableInterface $limitable): int
59
    {
60
        foreach ($this->limits as $name => $limit) {
61
            if ($limitable->getLimitableName() === $name) {
62
                if (!isset($limit['limit'])) {
63
                    throw new ParameterNotSetException('The limit is not set correctly');
64
                }
65
66
                return $limit['limit'];
67
            }
68
        }
69
70
        return -1;
71
    }
72
73
    public function getLimits(): array
74
    {
75
        return $this->limits;
76
    }
77
78
    public function getPriceId(): ?string
79
    {
80
        return $this->priceId;
81
    }
82
83
    public function setPriceId(string $priceId): void
84
    {
85
        $this->priceId = $priceId;
0 ignored issues
show
Bug Best Practice introduced by
The property priceId does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
86
    }
87
88
    /**
89
     * @throws NoPlanPriceFoundException
90
     */
91
    public function getPriceForPaymentSchedule(string $term, string $currency): PlanPrice
92
    {
93
        if (!isset($this->prices[$term][$currency])) {
94
            throw new NoPlanPriceFoundException(sprintf("No currency '%s' found for '%s' schedule found", $currency, $term));
95
        }
96
97
        return new PlanPrice($term, $this->prices[$term][$currency]['amount'], $currency, $this->prices[$term][$currency]['price_id'] ?? null, $this->prices[$term][$currency]['entity_id'] ?? null);
98
    }
99
100
    /**
101
     * @return PlanPrice[]
102
     */
103
    public function getPublicPrices(): array
104
    {
105
        $output = [];
106
        foreach ($this->prices as $term => $currencyData) {
107
            foreach ($currencyData as $currency => $data) {
108
                if (!$data['public']) {
109
                    continue;
110
                }
111
                $output[] = new PlanPrice($term, $data['amount'], $currency, $data['price_id'] ?? null, $data['entity_id'] ?? null);
112
            }
113
        }
114
115
        return $output;
116
    }
117
118
    public function getFeatures(): array
119
    {
120
        return $this->features;
121
    }
122
123
    public function isFree(): bool
124
    {
125
        return $this->isFree;
126
    }
127
128
    public function isPerSeat(): bool
129
    {
130
        return $this->isPerSeat;
131
    }
132
133
    public function getUserCount(): int
134
    {
135
        return $this->userCount;
136
    }
137
138
    public function setPrices(array $prices): void
139
    {
140
        $this->prices = $prices;
141
    }
142
143
    public function isPublic(): bool
144
    {
145
        return $this->public;
146
    }
147
148
    public function getHasTrial(): bool
149
    {
150
        return true === $this->hasTrial;
151
    }
152
153
    public function setHasTrial(?bool $hasTrial): void
154
    {
155
        $this->hasTrial = $hasTrial;
156
    }
157
158
    public function getTrialLengthDays(): int
159
    {
160
        return (int) $this->trialLengthDays;
161
    }
162
163
    public function setTrialLengthDays(?int $trialLengthDays): void
164
    {
165
        $this->trialLengthDays = $trialLengthDays;
166
    }
167
168
    public function getEntityId(): mixed
169
    {
170
        return $this->entityId;
171
    }
172
173
    public function setEntityId(mixed $entityId): void
174
    {
175
        $this->entityId = $entityId;
176
    }
177
178
    public function hasEntityId(): bool
179
    {
180
        return isset($this->entityId);
181
    }
182
}
183