Completed
Push — develop ( 4fb2cb...24ed31 )
by Ravan
01:21
created

example.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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 8 and the first side effect is on line 3.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
include "vendor/autoload.php";
4
5
/**
6
 * Implements the Axado\Volume\VolumeInterface and uses Axado\Volume\VolumeTrait.
7
 */
8
class Stub implements Axado\Volume\VolumeInterface {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
    use Axado\Volume\VolumeTrait;
10
11
    public function getSku()       { return "123"; }
12
    public function getQuantity()  { return 10; }
13
    public function getPriceUnit() { return 10.5; }
14
    public function getHeight()    { return 10; }
15
    public function getLength()    { return 10; }
16
    public function getWidth()     { return 10; }
17
    public function getWeight()    { return 10; }
18
}
19
20
/**
21
 * Set the token api.
22
 */
23
\Axado\Shipping::$token = "your-token";
24
25
/**
26
 * Create a Axado Shipping.
27
 */
28
$shipping = new Axado\Shipping;
29
30
/**
31
 * Setting a sale order infos
32
 */
33
$shipping->setPostalCodeOrigin('04661100');
0 ignored issues
show
'04661100' is of type string, but the function expects a object<Axado\strin>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
34
$shipping->setPostalCodeDestination('13301430');
0 ignored issues
show
'13301430' is of type string, but the function expects a object<Axado\strin>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
35
$shipping->setAditionalPrice('12.6%');
36
$shipping->setTotalPrice('40');
37
$shipping->setAditionalDays('10');
38
39
dd($shipping->getAttributes());
40
41
/**
42
 * Add volumes to shipping
43
 */
44
$volume = new Stub;
45
$shipping->addVolume($volume);
46
47
/**
48
 * Getting all quotations
49
 */
50
var_dump($shipping->quotations());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($shipping->quotations()); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
51
52
/**
53
 * Get the costs and dealine to the first Quotation.
54
 */
55
var_dump($shipping->getCosts());     // in reais
56
var_dump($shipping->getDeadline());  // in days
57
58
$shipping->flagAsContracted();
59