Issues (21)

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/Shipment/Partial/Detail.php (5 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
namespace MrPrompt\Centercob\Shipment\Partial;
3
4
use MrPrompt\ShipmentCommon\Base\Charge;
5
use MrPrompt\ShipmentCommon\Base\Holder;
6
use MrPrompt\ShipmentCommon\Base\Seller;
7
use MrPrompt\ShipmentCommon\Base\Parcels;
8
use MrPrompt\ShipmentCommon\Type\Numeric;
9
use MrPrompt\ShipmentCommon\Base\Customer;
10
use MrPrompt\ShipmentCommon\Base\Sequence;
11
use MrPrompt\ShipmentCommon\Base\Purchaser;
12
use MrPrompt\ShipmentCommon\Base\CreditCard;
13
use MrPrompt\ShipmentCommon\Base\Dealership;
14
use MrPrompt\ShipmentCommon\Base\BankAccount;
15
use MrPrompt\ShipmentCommon\Type\Alphanumeric;
16
use MrPrompt\ShipmentCommon\Base\Authorization;
17
use MrPrompt\ShipmentCommon\Base\ConsumerUnity;
18
19
/**
20
 * File detail
21
 *
22
 * @author Thiago Paes <[email protected]>
23
 */
24
class Detail extends \stdClass
25
{
26
    /**
27
     * Type of register
28
     *
29
     * @var string
30
     */
31
    const TYPE = 'D';
32
33
    /**
34
     * Shipment code
35
     *
36
     * @var int
37
     */
38
    const SHIPPING = 2;
39
40
    /**
41
     * Date Format
42
     *
43
     * @var string
44
     */
45
    const DATE_FORMAT = 'dmY';
46
47
    /**
48
     * Customer
49
     *
50
     * @var Customer
51
     */
52
    private $customer;
53
54
    /**
55
     * Charge
56
     *
57
     * @var charge
58
     */
59
    private $charge;
60
61
    /**
62
     * Consumer Unity
63
     *
64
     * @var ConsumerUnity
65
     */
66
    private $consumerUnity;
67
68
    /**
69
     * Dealership
70
     *
71
     * @var Dealership
72
     */
73
    private $dealership;
74
75
    /**
76
     * Seller
77
     *
78
     * @var Seller
79
     */
80
    private $seller;
81
82
    /**
83
     * Purchaser
84
     *
85
     * @var Purchaser
86
     */
87
    private $purchaser;
88
89
    /**
90
     * Bank account
91
     *
92
     * @var BankAccount
93
     */
94
    private $bankAccount;
95
96
    /**
97
     * Parcels
98
     *
99
     * @var Parcels
100
     */
101
    private $parcels;
102
103
    /**
104
     * Authorization
105
     *
106
     * @var Authorization
107
     */
108
    private $authorization;
109
110
    /**
111
     * Credit Card
112
     *
113
     * @var CreditCard
114
     */
115
    private $creditCard;
116
117
    /**
118
     * Sequence
119
     *
120
     * @var Sequence
121
     */
122
    private $sequence;
123
124
    /**
125
     * Holder
126
     *
127
     * @var Holder
128
     */
129
    private $holder;
130
131
    /**
132
     * Constructor
133
     *
134
     * @param Customer $customer
135
     * @param Charge $charge
136
     * @param Seller $seller
137
     * @param Purchaser $purchaser
138
     * @param Parcels $parcels
139
     * @param Authorization $authorization
140
     * @param CreditCard $creditCard
141
     * @param BankAccount $bankAccount
142
     * @param ConsumerUnity $consumerUnity
143
     * @param Sequence $sequence
144
     */
145 21
    public function __construct(
146
        Customer $customer,
147
        Charge $charge,
148
        Seller $seller,
149
        Purchaser $purchaser,
150
        Parcels $parcels,
151
        Authorization $authorization,
152
        CreditCard $creditCard,
153
        BankAccount $bankAccount,
154
        ConsumerUnity $consumerUnity,
155
        Sequence $sequence
156
    ) {
157 21
        $this->customer         = $customer;
158 21
        $this->charge           = $charge;
0 ignored issues
show
Documentation Bug introduced by
It seems like $charge of type object<MrPrompt\ShipmentCommon\Base\Charge> is incompatible with the declared type object<MrPrompt\Centerco...hipment\Partial\charge> of property $charge.

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...
159 21
        $this->consumerUnity    = $consumerUnity;
160 21
        $this->seller           = $seller;
161 21
        $this->purchaser        = $purchaser;
162 21
        $this->bankAccount      = $bankAccount;
163 21
        $this->parcels          = $parcels;
164 21
        $this->authorization    = $authorization;
165 21
        $this->creditCard       = $creditCard;
166 21
        $this->sequence         = $sequence;
167 21
        $this->dealership       = new Dealership();
168 21
        $this->holder           = new Holder();
169
170 21
        switch ($this->charge->getCharging()) {
171 21
            case Charge::CREDIT_CARD:
172
                $this->dealership->setCode($this->creditCard->getFlag());
173
                break;
174
175 21
            case Charge::DEBIT:
176 21
                $this->dealership->setCode($this->bankAccount->getBank()->getCode());
177 21
                break;
178
179
            case Charge::ENERGY:
180
                $this->dealership->setCode($this->consumerUnity->getCode());
181
                break;
182
183
            case Charge::BILLET:
184
                $this->dealership->setCode($this->bankAccount->getBank()->getCode());
185
                break;
186
        }
187 21
    }
188
189
    /**
190
     * @return Customer
191
     */
192 1
    public function getCustomer()
193
    {
194 1
        return $this->customer;
195
    }
196
197
    /**
198
     * @param Customer $customer
199
     */
200 1
    public function setCustomer(Customer $customer)
201
    {
202 1
        $this->customer = $customer;
203 1
    }
204
205
    /**
206
     * @return Charge
207
     */
208 1
    public function getCharge()
209
    {
210 1
        return $this->charge;
211
    }
212
213
    /**
214
     * @param Charge $charge
215
     */
216 1
    public function setCharge(Charge $charge)
217
    {
218 1
        $this->charge = $charge;
0 ignored issues
show
Documentation Bug introduced by
It seems like $charge of type object<MrPrompt\ShipmentCommon\Base\Charge> is incompatible with the declared type object<MrPrompt\Centerco...hipment\Partial\charge> of property $charge.

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...
219 1
    }
220
221
    /**
222
     * @return ConsumerUnity
223
     */
224 1
    public function getConsumerUnity()
225
    {
226 1
        return $this->consumerUnity;
227
    }
228
229
    /**
230
     * @param ConsumerUnity $consumerUnity
231
     */
232 1
    public function setConsumerUnity(ConsumerUnity $consumerUnity)
233
    {
234 1
        $this->consumerUnity = $consumerUnity;
235 1
    }
236
237
    /**
238
     * @return Seller
239
     */
240 1
    public function getSeller()
241
    {
242 1
        return $this->seller;
243
    }
244
245
    /**
246
     * @param Seller $seller
247
     */
248 1
    public function setSeller(Seller $seller)
249
    {
250 1
        $this->seller = $seller;
251 1
    }
252
253
    /**
254
     * @return Purchaser
255
     */
256 1
    public function getPurchaser()
257
    {
258 1
        return $this->purchaser;
259
    }
260
261
    /**
262
     * @param Purchaser $purchaser
263
     */
264 1
    public function setPurchaser(Purchaser $purchaser)
265
    {
266 1
        $this->purchaser = $purchaser;
267 1
    }
268
269
    /**
270
     * @return BankAccount
271
     */
272 1
    public function getBankAccount()
273
    {
274 1
        return $this->bankAccount;
275
    }
276
277
    /**
278
     * @param BankAccount $bankAccount
279
     */
280 1
    public function setBankAccount(BankAccount $bankAccount)
281
    {
282 1
        $this->bankAccount = $bankAccount;
283 1
    }
284
285
    /**
286
     * @return Parcels
287
     */
288 1
    public function getParcels()
289
    {
290 1
        return $this->parcels;
291
    }
292
293
    /**
294
     * @param Parcels $parcels
295
     */
296 1
    public function setParcels(Parcels $parcels)
297
    {
298 1
        $this->parcels = $parcels;
299 1
    }
300
301
    /**
302
     * @return Authorization
303
     */
304 1
    public function getAuthorization()
305
    {
306 1
        return $this->authorization;
307
    }
308
309
    /**
310
     * @param Authorization $authorization
311
     */
312 1
    public function setAuthorization(Authorization $authorization)
313
    {
314 1
        $this->authorization = $authorization;
315 1
    }
316
317
    /**
318
     * @return CreditCard
319
     */
320 1
    public function getCreditCard()
321
    {
322 1
        return $this->creditCard;
323
    }
324
325
    /**
326
     * @param CreditCard $creditCard
327
     */
328 1
    public function setCreditCard(CreditCard $creditCard)
329
    {
330 1
        $this->creditCard = $creditCard;
331 1
    }
332
333
    /**
334
     * @return Sequence
335
     */
336 1
    public function getSequence()
337
    {
338 1
        return $this->sequence;
339
    }
340
341
    /**
342
     * @param Sequence $sequence
343
     */
344 1
    public function setSequence(Sequence $sequence)
345
    {
346 1
        $this->sequence = $sequence;
347 1
    }
348
349
    /**
350
     * Render detail registry line
351
     *
352
     * @return string
353
     */
354 1
    public function render()
355
    {
356
        // Register code
357 1
        $result  = str_pad(self::TYPE, 1, Alphanumeric::FILL, Alphanumeric::ALIGN);
358
359
        // Shipping code
360 1
        $result .= str_pad(self::SHIPPING, 1, Numeric::FILL, Numeric::ALIGN);
361
362
        // Customer code
363 1
        $result .= substr(str_pad($this->customer->getCode(), 6, Numeric::FILL, Numeric::ALIGN), 0, 6);
364
365
        // Charging type
366 1
        $result .= substr(str_pad($this->charge->getCharging(), 1, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 1);
367
368
        // Consumer Unity from client
369 1
        $result .= substr(str_pad($this->consumerUnity->getNumber(), 25, Numeric::FILL, Numeric::ALIGN), 0, 25);
370
371
        // white space
372 1
        $result .= str_pad('', 10, Numeric::FILL, Numeric::ALIGN);
373
374
        // Occurrence type
375 1
        $result .= substr(str_pad($this->charge->getOccurrence()->getType(), 1, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 1);
376
377
        // white space
378 1
        $result .= str_pad('', 24, Alphanumeric::FILL, Alphanumeric::ALIGN);
379
380
        // City, state and Postal Code
381 1
        $result .= substr(str_pad($this->purchaser->getAddress()->getCity(), 50, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 50);
382 1
        $result .= substr(str_pad($this->purchaser->getAddress()->getState(), 2, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 2);
383 1
        $result .= substr(str_pad($this->purchaser->getAddress()->getPostalCode(), 8, Numeric::FILL, Numeric::ALIGN), 0, 8);
384
385
        // Dealership code
386 1
        $result .= substr(str_pad($this->dealership->getCode(), 6, Numeric::FILL, Numeric::ALIGN), 0, 6);
387
388
        // Seller code
389 1
        $result .= substr(str_pad($this->seller->getCode(), 6, Numeric::FILL, Numeric::ALIGN), 0, 6);
390
391
        // energy charge type
392 1
        $result .= substr($this->consumerUnity->getRead()->format(self::DATE_FORMAT), 0, 8);
393 1
        $result .= substr($this->consumerUnity->getMaturity()->format(self::DATE_FORMAT), 0, 8);
394
395
        // type person
396 1
        $result .= substr(str_pad($this->seller->getPerson(), 1, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 1);
397
398
        // person name
399 1
        $result .= substr(str_pad($this->purchaser->getName(), 70, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 70);
400
401
        // fantasy name
402 1
        $result .= substr(str_pad($this->purchaser->getFantasyName(), 70, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 70);
403
404
        // social reason
405 1
        $result .= substr(str_pad($this->purchaser->getSocialReason(), 70, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 70);
406
407
        // document number
408 1
        $result .= substr(str_pad($this->purchaser->getDocument()->getNumber(), 15, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 15);
409 1
        $result .= substr(str_pad($this->purchaser->getStateRegistration(), 20, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 20);
410
411
        // purchaser birth day
412 1
        $result .= $this->purchaser->getBirth()->format(self::DATE_FORMAT);
413
414 1
        $result .= substr(str_pad($this->purchaser->getEmail()->getAddress(), 50, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 50);
415 1
        $result .= substr(str_pad($this->purchaser->getAddress()->getAddress(), 50, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 50);
416 1
        $result .= substr(str_pad($this->purchaser->getAddress()->getNumber(), 6, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 6);
417 1
        $result .= substr(str_pad($this->purchaser->getAddress()->getDistrict(), 30, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 30);
418 1
        $result .= substr(str_pad($this->purchaser->getAddress()->getComplement(), 30, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 30);
419 1
        $result .= substr(str_pad($this->purchaser->getHomePhone()->getNumber(), 11, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 11);
420 1
        $result .= substr(str_pad($this->purchaser->getHomePhoneSecondary()->getNumber(), 11, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 11);
421 1
        $result .= substr(str_pad($this->purchaser->getCellPhone()->getNumber(), 11, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 11);
422
423
        // whitespace
424 1
        $result .= str_pad('', 7, Alphanumeric::FILL, Alphanumeric::ALIGN);
425
426
        // fathers
427 1
        $result .= substr(str_pad($this->purchaser->getFatherName(), 50, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 50);
428 1
        $result .= substr(str_pad($this->purchaser->getMotherName(), 50, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 50);
429
430
        // maturity date from first parcel
431 1
        $result .= substr($this->parcels->offsetGet(0)->getMaturity()->format(self::DATE_FORMAT), 0, 8);
432
433
        // first parcel
434 1
        $result .= substr(str_pad($this->parcels->offsetGet(0)->getPrice(), 10, Numeric::FILL, Numeric::ALIGN), 0, 10);
435 1
        $result .= substr(str_pad($this->parcels->offsetGet(0)->getQuantity(), 2, Numeric::FILL, Numeric::ALIGN), 0, 2);
436
437
        // second parcel
438 1 View Code Duplication
        if ($this->parcels->offsetExists(1)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
439 1
            $result .= substr(str_pad($this->parcels->offsetGet(1)->getPrice(), 10, Numeric::FILL, Numeric::ALIGN), 0, 10);
440 1
            $result .= substr(str_pad($this->parcels->offsetGet(1)->getQuantity(), 2, Numeric::FILL, Numeric::ALIGN), 0, 2);
441
        } else {
442
            $result .= substr(str_pad(0, 10, Numeric::FILL, Numeric::ALIGN), 0, 10);
443
            $result .= substr(str_pad(0, 2, Numeric::FILL, Numeric::ALIGN), 0, 2);
444
        }
445
446
        // third parcel
447 1 View Code Duplication
        if ($this->parcels->offsetExists(2)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
448 1
            $result .= substr(str_pad($this->parcels->offsetGet(2)->getPrice(), 10, Numeric::FILL, Numeric::ALIGN), 0, 10);
449 1
            $result .= substr(str_pad($this->parcels->offsetGet(2)->getQuantity(), 2, Numeric::FILL, Numeric::ALIGN), 0, 2);
450
        } else {
451
            $result .= substr(str_pad(0, 10, Numeric::FILL, Numeric::ALIGN), 0, 10);
452
            $result .= substr(str_pad(0, 2, Numeric::FILL, Numeric::ALIGN), 0, 2);
453
        }
454
455
        // fourth parcel
456 1 View Code Duplication
        if ($this->parcels->offsetExists(3)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
457 1
            $result .= substr(str_pad($this->parcels->offsetGet(3)->getPrice(), 10, Numeric::FILL, Numeric::ALIGN), 0, 10);
458 1
            $result .= substr(str_pad($this->parcels->offsetGet(3)->getQuantity(), 2, Numeric::FILL, Numeric::ALIGN), 0, 2);
459
        } else {
460
            $result .= substr(str_pad(0, 10, Numeric::FILL, Numeric::ALIGN), 0, 10);
461
            $result .= substr(str_pad(0, 2, Numeric::FILL, Numeric::ALIGN), 0, 2);
462
        }
463
464
        // authorization number
465 1
        $result .= substr(str_pad($this->authorization->getNumber(), 10, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 10);
466
467
        // occurrence code return
468 1
        $result .= substr(str_pad($this->charge->getOccurrence()->getReturn(), 2, Numeric::FILL, Numeric::ALIGN), 0, 2);
469
470
        // occurrence description
471 1
        $result .= substr(str_pad($this->charge->getOccurrence()->getDescription(), 100, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 100);
472
473
        // customer identity number
474 1
        $result .= substr(str_pad($this->customer->getIdentityNumber(), 25, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 25);
475
476
        // agency (only to automatic debit)
477 1
        $result .= substr(str_pad($this->bankAccount->getBank()->getAgency(), 8, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 8);
478 1
        $result .= substr(str_pad($this->bankAccount->getBank()->getDigit(), 3, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 3);
479
480
        // account (only to automatic debit)
481 1
        $result .= substr(str_pad($this->bankAccount->getNumber(), 12, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 12);
482 1
        $result .= substr(str_pad($this->bankAccount->getDigit(), 3, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 3);
483 1
        $result .= substr(str_pad($this->bankAccount->getOperation(), 4, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 4);
484 1
        $result .= substr(str_pad(($this->bankAccount->getSecurity() ? 'S' : 'N'), 1, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 1);
485
486
        // credit card (only for credit card payments, of course)
487 1
        $result .= substr(str_pad($this->creditCard->getNumber(), 16, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 16);
488 1
        $result .= str_pad('', 3, Alphanumeric::FILL, Alphanumeric::ALIGN);
489 1
        $result .= substr($this->creditCard->getValidate()->format('mY'), 0, 6);
490 1
        $result .= substr(str_pad($this->creditCard->getSecurityNumber(), 5, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 5);
491
492
        // Helpful maturity
493 1
        $result .= substr(str_pad(($this->customer->getHelpfulMaturity() ? 'S' : 'N'), 1, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 1);
494
495
        // Working days
496 1
        $result .= substr(str_pad($this->customer->getWorkingDays(), 2, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 2);
497
498
        // type person of purchaser
499 1
        $result .= substr(str_pad($this->purchaser->getPerson(), 1, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 1);
500
501
        // document from purchaser
502 1
        $result .= substr(str_pad($this->purchaser->getDocument()->getNumber(), 20, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 20);
503
504
        // white spaces
505 1
        $result .= str_pad('', 5, Alphanumeric::FILL, Alphanumeric::ALIGN);
506
507
        // sequence number from line
508 1
        $result .= substr(str_pad($this->sequence->getValue(), 6, Numeric::FILL, Numeric::ALIGN), 0, 6);
509
510
        // resulting....
511 1
        return $result;
512
    }
513
}
514