Completed
Push — master ( f3d682...6367b5 )
by Gilmar
21:40
created

Order   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 91.67%

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 6
c 5
b 1
f 0
lcom 1
cbo 1
dl 0
loc 59
ccs 11
cts 12
cp 0.9167
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getSchema() 0 23 1
A getShipping() 0 10 2
A getInvoice() 0 4 1
A getItems() 0 4 1
A check() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of gpupo/netshoes-sdk
5
 * Created by Gilmar Pupo <[email protected]>
6
 * For the information of copyright and license you should read the file
7
 * LICENSE which is distributed with this source code.
8
 * Para a informação dos direitos autorais e de licença você deve ler o arquivo
9
 * LICENSE que é distribuído com este código-fonte.
10
 * Para obtener la información de los derechos de autor y la licencia debe leer
11
 * el archivo LICENSE que se distribuye con el código fuente.
12
 * For more information, see <http://www.g1mr.com/>.
13
 */
14
15
namespace Gpupo\NetshoesSdk\Entity\Order;
16
17
use Gpupo\CommonSdk\Entity\EntityAbstract;
18
use Gpupo\CommonSdk\Entity\EntityInterface;
19
20
/**
21
 * @method string getAgreedDate()    Acesso a agreedDate
22
 * @method setAgreedDate(string $agreedDate)    Define agreedDate
23
 * @method string getBusinessUnit()    Acesso a businessUnit
24
 * @method setBusinessUnit(string $businessUnit)    Define businessUnit
25
 * @method bool getDevolutionRequested()    Acesso a devolutionRequested
26
 * @method setDevolutionRequested(boolean $devolutionRequested)    Define devolutionRequested
27
 * @method bool getExchangeRequested()    Acesso a exchangeRequested
28
 * @method setExchangeRequested(boolean $exchangeRequested)    Define exchangeRequested
29
 * @method string getOrderDate()    Acesso a orderDate
30
 * @method setOrderDate(string $orderDate)    Define orderDate
31
 * @method string getOrderNumber()    Acesso a orderNumber
32
 * @method setOrderNumber(string $orderNumber)    Define orderNumber
33
 * @method string getOrderStatus()    Acesso a orderStatus
34
 * @method setOrderStatus(string $orderStatus)    Define orderStatus
35
 * @method string getOrderType()    Acesso a orderType
36
 * @method setOrderType(string $orderType)    Define orderType
37
 * @method string getOriginNumber()    Acesso a originNumber
38
 * @method setOriginNumber(string $originNumber)    Define originNumber
39
 * @method string getOriginSite()    Acesso a originSite
40
 * @method setOriginSite(string $originSite)    Define originSite
41
 * @method string getPaymentDate()    Acesso a paymentDate
42
 * @method setPaymentDate(string $paymentDate)    Define paymentDate
43
 * @method Gpupo\NetshoesSdk\Entity\Order\Shippings\Shippings getShippings()    Acesso a shippings
44
 * @method setShippings(Gpupo\NetshoesSdk\Entity\Order\Shippings\Shippings $shippings)    Define shippings
45
 * @method float getTotalCommission()    Acesso a totalCommission
46
 * @method setTotalCommission(float $totalCommission)    Define totalCommission
47
 * @method float getTotalDiscount()    Acesso a totalDiscount
48
 * @method setTotalDiscount(float $totalDiscount)    Define totalDiscount
49
 * @method float getTotalFreight()    Acesso a totalFreight
50
 * @method setTotalFreight(float $totalFreight)    Define totalFreight
51
 * @method float getTotalGross()    Acesso a totalGross
52
 * @method setTotalGross(float $totalGross)    Define totalGross
53
 * @method float getTotalNet()    Acesso a totalNet
54
 * @method setTotalNet(float $totalNet)    Define totalNet
55
 * @method float getTotalQuantity()    Acesso a totalQuantity
56
 * @method setTotalQuantity(float $totalQuantity)    Define totalQuantity
57
 */
58
class Order extends EntityAbstract implements EntityInterface
59
{
60
    protected $primaryKey = 'orderNumber';
61
62
    /**
63
     * @codeCoverageIgnore
64
     */
65
    public function getSchema()
66
    {
67
        return [
68
            'agreedDate'          => 'string',
69
            'businessUnit'        => 'string',
70
            'devolutionRequested' => 'boolean',
71
            'exchangeRequested'   => 'boolean',
72
            'orderDate'           => 'string',
73
            'orderNumber'         => 'string',
74
            'orderStatus'         => 'string',
75
            'orderType'           => 'string',
76
            'originNumber'        => 'string',
77
            'originSite'          => 'string',
78
            'paymentDate'         => 'string',
79
            'shippings'           => 'object',
80
            'totalCommission'     => 'number',
81
            'totalDiscount'       => 'number',
82
            'totalFreight'        => 'number',
83
            'totalGross'          => 'number',
84
            'totalNet'            => 'number',
85
            'totalQuantity'       => 'number',
86
        ];
87
    }
88
89 11
    public function getShipping()
90
    {
91 11
        $shipping = $this->getShippings()->first();
92
93 11
        if (empty($shipping)) {
94
            throw new \Exception('Shipping Missed!');
95
        }
96
97 11
        return $shipping;
98
    }
99
100 4
    public function getInvoice()
101
    {
102 4
        return $this->getShipping()->getInvoice();
103
    }
104
105 1
    public function getItems()
106
    {
107 1
        return $this->getShipping()->getItems();
108
    }
109
110 15
    public function check()
111
    {
112 15
        $this->setRequiredSchema(['businessUnit', 'orderDate', 'orderNumber']);
113
114 15
        return $this->isValid();
115
    }
116
}
117