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/Customer/Customer.php (6 issues)

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\Customer;
11
12
use Money\Currency;
13
use Shapin\Stripe\Exception\LogicException;
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
use Shapin\Stripe\Model\Source\Source;
20
use Shapin\Stripe\Model\Source\SourceCollection;
21
use Shapin\Stripe\Model\Subscription\Subscription;
22
use Shapin\Stripe\Model\Subscription\SubscriptionCollection;
23
24
final class Customer implements CreatableFromArray, ContainsMetadata
25
{
26
    use LivemodeTrait;
27
    use MetadataTrait;
28
29
    /**
30
     * @var string
31
     */
32
    private $id;
33
34
    /**
35
     * @var int
36
     */
37
    private $balance;
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 $defaultSourceId;
53
54
    /**
55
     * @var bool
56
     */
57
    private $delinquent;
58
59
    /**
60
     * @var ?string
61
     */
62
    private $description;
63
64
    /**
65
     * @var array
66
     */
67
    private $discount;
68
69
    /**
70
     * @var string
71
     */
72
    private $email;
73
74
    /**
75
     * @var string
76
     */
77
    private $invoicePrefix;
78
79
    /**
80
     * @var ?InvoiceSettings
81
     */
82
    private $invoiceSettings;
83
84
    /**
85
     * @var ?Shipping
86
     */
87
    private $shipping;
88
89
    /**
90
     * @var SourceCollection
91
     */
92
    private $sources;
93
94
    /**
95
     * @var SubscriptionCollection
96
     */
97
    private $subscriptions;
98
99
    /**
100
     * @var TaxInfo
101
     */
102
    private $taxInfo;
103
104
    /**
105
     * @var TaxInfoVerification
106
     */
107
    private $taxInfoVerification;
108
109 5
    private function __construct()
110
    {
111 5
    }
112
113 5
    public static function createFromArray(array $data): self
114
    {
115 5
        $model = new self();
116 5
        $model->id = $data['id'];
117 5
        $model->balance = (int) $data['balance'];
118 5
        $model->createdAt = new \DateTimeImmutable('@'.$data['created']);
119 5
        if (isset($data['currency'])) {
120 5
            $model->currency = new Currency(strtoupper($data['currency']));
121
        }
122 5
        $model->defaultSourceId = $data['default_source'];
123 5
        $model->delinquent = (bool) $data['delinquent'];
124 5
        $model->description = $data['description'];
125 5
        $model->discount = \array_key_exists('discount', $data) ? $data['discount'] : null;
126 5
        $model->email = $data['email'];
127 5
        $model->invoicePrefix = $data['invoice_prefix'];
128 5
        $model->invoiceSettings = \array_key_exists('invoice_settings', $data) ? InvoiceSettings::createFromArray($data['invoice_settings']) : null;
129 5
        $model->live = (bool) $data['livemode'];
130 5
        $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...
131 5
        if (isset($data['shipping'])) {
132
            $model->shipping = Shipping::createFromArray($data['shipping']);
133
        }
134 5
        $model->sources = SourceCollection::createFromArray($data['sources']);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Shapin\Stripe\Model\Sou...Array($data['sources']) of type object<self> is incompatible with the declared type object<Shapin\Stripe\Mod...ource\SourceCollection> of property $sources.

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...
135 5
        $model->subscriptions = SubscriptionCollection::createFromArray($data['subscriptions']);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Shapin\Stripe\Model\Sub...$data['subscriptions']) of type object<self> is incompatible with the declared type object<Shapin\Stripe\Mod...SubscriptionCollection> of property $subscriptions.

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...
136 5
        if (isset($data['tax_info'])) {
137
            $model->taxInfo = TaxInfo::createFromArray($data['tax_info']);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Shapin\Stripe\Model\Cus...rray($data['tax_info']) of type object<self> is incompatible with the declared type object<Shapin\Stripe\Model\Customer\TaxInfo> of property $taxInfo.

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...
138
        }
139 5
        if (isset($data['tax_info_verification'])) {
140
            $model->taxInfoVerification = TaxInfoVerification::createFromArray($data['tax_info_verification']);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Shapin\Stripe\Model\Cus...ax_info_verification']) of type object<self> is incompatible with the declared type object<Shapin\Stripe\Mod...er\TaxInfoVerification> of property $taxInfoVerification.

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...
141
        }
142
143 5
        return $model;
144
    }
145
146 1
    public function getId(): string
147
    {
148 1
        return $this->id;
149
    }
150
151
    public function getAccountBalance(): int
152
    {
153
        @trigger_error('Calling the method getAccountBalance is deprecated since Stripe API 2019-10-17. Use getBalance instead.', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
154
155
        return $this->balance;
156
    }
157
158 1
    public function getBalance(): int
159
    {
160 1
        return $this->balance;
161
    }
162
163 1
    public function getCreatedAt(): \DateTimeImmutable
164
    {
165 1
        return $this->createdAt;
166
    }
167
168 1
    public function getCurrency(): ?Currency
169
    {
170 1
        return $this->currency;
171
    }
172
173 1
    public function getDefaultSource(): ?Source
174
    {
175 1
        if (null === $this->defaultSourceId) {
176 1
            return null;
177
        }
178
179
        foreach ($this->sources->getElements() as $source) {
180
            if ($this->defaultSourceId === $source->getId()) {
181
                return $source;
182
            }
183
        }
184
185
        throw new LogicException('Unable to find default source in available sources.');
186
    }
187
188
    public function getDefaultSourceId(): ?string
189
    {
190
        return $this->defaultSourceId;
191
    }
192
193
    public function hasDefaultSource(): bool
194
    {
195
        return null !== $this->defaultSourceId;
196
    }
197
198 1
    public function isDelinquent(): bool
199
    {
200 1
        return $this->delinquent;
201
    }
202
203 1
    public function getDescription(): ?string
204
    {
205 1
        return $this->description;
206
    }
207
208 1
    public function getDiscount(): ?array
209
    {
210 1
        return $this->discount;
211
    }
212
213 1
    public function getEmail(): ?string
214
    {
215 1
        return $this->email;
216
    }
217
218 1
    public function getInvoicePrefix(): ?string
219
    {
220 1
        return $this->invoicePrefix;
221
    }
222
223 1
    public function getInvoiceSettings(): ?InvoiceSettings
224
    {
225 1
        return $this->invoiceSettings;
226
    }
227
228
    public function getShipping(): ?Shipping
229
    {
230
        return $this->shipping;
231
    }
232
233 1
    public function getSources(): SourceCollection
234
    {
235 1
        return $this->sources;
236
    }
237
238 1
    public function getSubscriptions(): SubscriptionCollection
239
    {
240 1
        return $this->subscriptions;
241
    }
242
243 1
    public function getLatestSubscription(): ?Subscription
244
    {
245 1
        $subscriptions = $this->subscriptions->getElements();
246 1
        if (0 === \count($subscriptions)) {
247
            return null;
248
        }
249
250 1
        return reset($subscriptions);
251
    }
252
253 1
    public function getTaxInfo(): ?TaxInfo
254
    {
255 1
        return $this->taxInfo;
256
    }
257
258 1
    public function getTaxInfoVerification(): ?TaxInfoVerification
259
    {
260 1
        return $this->taxInfoVerification;
261
    }
262
}
263