shapintv /
stripe
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 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* |
||
| 6 | * This software may be modified and distributed under the terms |
||
| 7 | * of the MIT license. See the LICENSE file for details. |
||
| 8 | */ |
||
| 9 | |||
| 10 | namespace Shapin\Stripe\Model\Plan; |
||
| 11 | |||
| 12 | use Money\Currency; |
||
| 13 | use Money\Money; |
||
| 14 | use Shapin\Stripe\Model\ContainsMetadata; |
||
| 15 | use Shapin\Stripe\Model\CreatableFromArray; |
||
| 16 | use Shapin\Stripe\Model\LivemodeTrait; |
||
| 17 | use Shapin\Stripe\Model\MetadataCollection; |
||
| 18 | use Shapin\Stripe\Model\MetadataTrait; |
||
| 19 | |||
| 20 | final class Plan implements CreatableFromArray, ContainsMetadata |
||
| 21 | { |
||
| 22 | use LivemodeTrait; |
||
| 23 | use MetadataTrait; |
||
| 24 | |||
| 25 | const AGGREGATE_USAGE_SUM = 'sum'; |
||
| 26 | const AGGREGATE_USAGE_LAST_DURING_PERIOD = 'last_during_period'; |
||
| 27 | const AGGREGATE_USAGE_LAST_EVER = 'last_ever'; |
||
| 28 | const AGGREGATE_USAGE_MAX = 'max'; |
||
| 29 | |||
| 30 | const BILLING_SCHEME_PER_UNIT = 'per_unit'; |
||
| 31 | const BILLING_SCHEME_TIERED = 'tiered'; |
||
| 32 | |||
| 33 | const INTERVAL_DAY = 'day'; |
||
| 34 | const INTERVAL_WEEK = 'week'; |
||
| 35 | const INTERVAL_MONTH = 'month'; |
||
| 36 | const INTERVAL_YEAR = 'year'; |
||
| 37 | |||
| 38 | const TIERS_MODE_GRADUATED = 'graduated'; |
||
| 39 | const TIERS_MODE_VOLUME = 'volume'; |
||
| 40 | |||
| 41 | const USAGE_TYPE_METERED = 'metered'; |
||
| 42 | const USAGE_TYPE_LICENSED = 'licensed'; |
||
| 43 | |||
| 44 | const ROUND_DOWN = 'down'; |
||
| 45 | const ROUND_UP = 'up'; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var string |
||
| 49 | */ |
||
| 50 | private $id; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var bool |
||
| 54 | */ |
||
| 55 | private $active; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @var ?string |
||
| 59 | */ |
||
| 60 | private $aggregateUsage; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @var Money |
||
| 64 | */ |
||
| 65 | private $amount; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @var string |
||
| 69 | */ |
||
| 70 | private $billingScheme; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @var \DateTimeImmutable |
||
| 74 | */ |
||
| 75 | private $createdAt; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @var Currency |
||
| 79 | */ |
||
| 80 | private $currency; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @var string |
||
| 84 | */ |
||
| 85 | private $interval; |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @var int |
||
| 89 | */ |
||
| 90 | private $intervalCount; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @var ?string |
||
| 94 | */ |
||
| 95 | private $nickname; |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @var string |
||
| 99 | */ |
||
| 100 | private $product; |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @var array |
||
| 104 | */ |
||
| 105 | private $tiers; |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @var ?string |
||
| 109 | */ |
||
| 110 | private $tiersMode; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * @var ?TransformUsage |
||
| 114 | */ |
||
| 115 | private $transformUsage; |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @var ?int |
||
| 119 | */ |
||
| 120 | private $trialPeriodDays; |
||
| 121 | |||
| 122 | /** |
||
| 123 | * @var string |
||
| 124 | */ |
||
| 125 | private $usageType; |
||
| 126 | |||
| 127 | 14 | public static function createFromArray(array $data): self |
|
| 128 | { |
||
| 129 | 14 | $currency = new Currency(strtoupper($data['currency'])); |
|
| 130 | |||
| 131 | 14 | $tiers = []; |
|
| 132 | 14 | if (isset($data['tiers'])) { |
|
| 133 | foreach ($data['tiers'] as $tier) { |
||
| 134 | $tiers[] = Tier::createFromArray($tier); |
||
| 135 | } |
||
| 136 | } |
||
| 137 | |||
| 138 | 14 | $model = new self(); |
|
| 139 | 14 | $model->id = $data['id']; |
|
| 140 | 14 | $model->active = (bool) $data['active']; |
|
| 141 | 14 | $model->aggregateUsage = $data['aggregate_usage']; |
|
| 142 | 14 | $model->amount = new Money($data['amount'], $currency); |
|
| 143 | 14 | $model->billingScheme = $data['billing_scheme']; |
|
| 144 | 14 | $model->createdAt = new \DateTimeImmutable('@'.$data['created']); |
|
| 145 | 14 | $model->currency = $currency; |
|
| 146 | 14 | $model->interval = $data['interval']; |
|
| 147 | 14 | $model->intervalCount = (int) $data['interval_count']; |
|
| 148 | 14 | $model->live = $data['livemode']; |
|
| 149 | 14 | $model->metadata = MetadataCollection::createFromArray($data['metadata']); |
|
|
0 ignored issues
–
show
|
|||
| 150 | 14 | $model->nickname = $data['nickname']; |
|
| 151 | 14 | $model->product = $data['product']; |
|
| 152 | 14 | $model->tiers = $tiers; |
|
| 153 | 14 | $model->tiersMode = $data['tiers_mode']; |
|
| 154 | 14 | $model->transformUsage = isset($data['transform_usage']) ? TransformUsage::createFromArray($data['transform_usage']) : null; |
|
| 155 | 14 | $model->trialPeriodDays = $data['trial_period_days']; |
|
| 156 | 14 | $model->usageType = $data['usage_type']; |
|
| 157 | |||
| 158 | 14 | return $model; |
|
| 159 | } |
||
| 160 | |||
| 161 | 1 | public function getId(): string |
|
| 162 | { |
||
| 163 | 1 | return $this->id; |
|
| 164 | } |
||
| 165 | |||
| 166 | 1 | public function isActive(): bool |
|
| 167 | { |
||
| 168 | 1 | return $this->active; |
|
| 169 | } |
||
| 170 | |||
| 171 | 1 | public function getAgregateUsage(): ?string |
|
| 172 | { |
||
| 173 | 1 | return $this->aggregateUsage; |
|
| 174 | } |
||
| 175 | |||
| 176 | 1 | public function getAmount(): Money |
|
| 177 | { |
||
| 178 | 1 | return $this->amount; |
|
| 179 | } |
||
| 180 | |||
| 181 | 1 | public function getBilingScheme(): string |
|
| 182 | { |
||
| 183 | 1 | return $this->billingScheme; |
|
| 184 | } |
||
| 185 | |||
| 186 | 1 | public function getCreatedAt(): \DateTimeImmutable |
|
| 187 | { |
||
| 188 | 1 | return $this->createdAt; |
|
| 189 | } |
||
| 190 | |||
| 191 | 1 | public function getCurrency(): Currency |
|
| 192 | { |
||
| 193 | 1 | return $this->currency; |
|
| 194 | } |
||
| 195 | |||
| 196 | 1 | public function getInterval(): string |
|
| 197 | { |
||
| 198 | 1 | return $this->interval; |
|
| 199 | } |
||
| 200 | |||
| 201 | 1 | public function getIntervalCount(): int |
|
| 202 | { |
||
| 203 | 1 | return $this->intervalCount; |
|
| 204 | } |
||
| 205 | |||
| 206 | 1 | public function getNickname(): ?string |
|
| 207 | { |
||
| 208 | 1 | return $this->nickname; |
|
| 209 | } |
||
| 210 | |||
| 211 | 1 | public function getProduct(): string |
|
| 212 | { |
||
| 213 | 1 | return $this->product; |
|
| 214 | } |
||
| 215 | |||
| 216 | 1 | public function getTiers(): array |
|
| 217 | { |
||
| 218 | 1 | return $this->tiers; |
|
| 219 | } |
||
| 220 | |||
| 221 | 1 | public function getTiersMode(): ?string |
|
| 222 | { |
||
| 223 | 1 | return $this->tiersMode; |
|
| 224 | } |
||
| 225 | |||
| 226 | 1 | public function getTransformUsage(): ?TransformUsage |
|
| 227 | { |
||
| 228 | 1 | return $this->transformUsage; |
|
| 229 | } |
||
| 230 | |||
| 231 | 1 | public function getTrialPeriodDays(): ?int |
|
| 232 | { |
||
| 233 | 1 | return $this->trialPeriodDays; |
|
| 234 | } |
||
| 235 | |||
| 236 | 1 | public function getUsageType(): string |
|
| 237 | { |
||
| 238 | 1 | return $this->usageType; |
|
| 239 | } |
||
| 240 | } |
||
| 241 |
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..