Issues (93)

Security Analysis    no request data  

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

  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  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.
  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.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
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/Model/Coupon/Coupon.php (1 issue)

Upgrade to new PHP Analysis Engine

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\Coupon;
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 Coupon implements CreatableFromArray, ContainsMetadata
21
{
22
    use LivemodeTrait;
23
    use MetadataTrait;
24
25
    const DURATION_FOREVER = 'forever';
26
    const DURATION_ONCE = 'once';
27
    const DURATION_REPEATING = 'repeating';
28
29
    /**
30
     * @var string
31
     */
32
    private $id;
33
34
    /**
35
     * @var ?Money
36
     */
37
    private $amountOff;
38
39
    /**
40
     * @var \DateTimeImmutable
41
     */
42
    private $createdAt;
43
44
    /**
45
     * @var ?Currency
46
     */
47
    private $currency;
48
49
    /**
50
     * @var string
51
     */
52
    private $duration;
53
54
    /**
55
     * @var int
56
     */
57
    private $durationInMonths;
58
59
    /**
60
     * @var ?int
61
     */
62
    private $maxRedemptions;
63
64
    /**
65
     * @var string
66
     */
67
    private $name;
68
69
    /**
70
     * @var float
71
     */
72
    private $percentOff;
73
74
    /**
75
     * @var ?\DateTimeImmutable
76
     */
77
    private $redeemBy;
78
79
    /**
80
     * @var int
81
     */
82
    private $timesRedeemed;
83
84
    /**
85
     * @var bool
86
     */
87
    private $valid;
88
89 9
    public static function createFromArray(array $data): self
90
    {
91 9
        $model = new self();
92
93 9
        if (isset($data['currency'])) {
94
            $currency = new Currency(strtoupper($data['currency']));
95
96
            $model->amountOff = isset($data['amount_off']) ? new Money($data['amount_off'], $currency) : null;
97
            $model->currency = $currency;
98
        }
99
100 9
        $model->id = $data['id'];
101 9
        $model->createdAt = new \DateTimeImmutable('@'.$data['created']);
102 9
        $model->duration = $data['duration'];
103 9
        $model->durationInMonths = (int) $data['duration_in_months'];
104 9
        $model->live = $data['livemode'];
105 9
        $model->maxRedemptions = $data['max_redemptions'] ?? null;
106 9
        $model->metadata = MetadataCollection::createFromArray($data['metadata']);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Shapin\Stripe\Model\Met...rray($data['metadata']) of type object<self> is incompatible with the declared type object<Shapin\Stripe\Model\MetadataCollection> of property $metadata.

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..

Loading history...
107 9
        $model->name = $data['name'];
108 9
        $model->percentOff = (float) $data['percent_off'];
109 9
        $model->redeemBy = isset($data['redeem_by']) ? new \DateTimeImmutable('@'.$data['redeem_by']) : null;
110 9
        $model->timesRedeemed = (int) $data['times_redeemed'];
111 9
        $model->valid = (bool) $data['valid'];
112
113 9
        return $model;
114
    }
115
116
    public function isRepeating(): bool
117
    {
118
        return self::DURATION_REPEATING === $this->duration;
119
    }
120
121
    public function isOnce(): bool
122
    {
123
        return self::DURATION_ONCE === $this->duration;
124
    }
125
126
    public function isForever(): bool
127
    {
128
        return self::DURATION_FOREVER === $this->duration;
129
    }
130
131 1
    public function getId(): string
132
    {
133 1
        return $this->id;
134
    }
135
136 1
    public function getAmountOff(): ?Money
137
    {
138 1
        return $this->amountOff;
139
    }
140
141 1
    public function getCreatedAt(): \DateTimeImmutable
142
    {
143 1
        return $this->createdAt;
144
    }
145
146 1
    public function getCurrency(): ?Currency
147
    {
148 1
        return $this->currency;
149
    }
150
151 1
    public function getDuration(): string
152
    {
153 1
        return $this->duration;
154
    }
155
156 1
    public function getDurationInMonths(): int
157
    {
158 1
        return $this->durationInMonths;
159
    }
160
161 1
    public function getMaxRedemptions(): ?int
162
    {
163 1
        return $this->maxRedemptions;
164
    }
165
166 1
    public function getName(): ?string
167
    {
168 1
        return $this->name;
169
    }
170
171
    public function getPercentOff(): float
172
    {
173
        return $this->percentOff;
174
    }
175
176 1
    public function getRedeemBy(): ?\DateTimeImmutable
177
    {
178 1
        return $this->redeemBy;
179
    }
180
181 1
    public function getTimesRedeemed(): int
182
    {
183 1
        return $this->timesRedeemed;
184
    }
185
186 1
    public function isValid(): bool
187
    {
188 1
        return $this->valid;
189
    }
190
}
191