Completed
Push — master ( d34f34...c67d8d )
by Gilmar
23:17
created

Invoice   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 8
Bugs 0 Features 0
Metric Value
wmc 7
c 8
b 0
f 0
lcom 1
cbo 2
dl 0
loc 51
rs 10
ccs 8
cts 8
cp 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getSchema() 0 11 1
A beforeConstruct() 0 8 3
A check() 0 7 1
A getIssueDate() 0 4 1
A getShipDate() 0 4 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\Shippings;
16
17
use Gpupo\CommonSdk\Entity\EntityAbstract;
18
use Gpupo\CommonSdk\Entity\EntityInterface;
19
use Gpupo\NetshoesSdk\Traits\DateTimeTrait;
20
21
/**
22
 * @method string getNumber()    Acesso a number
23
 * @method setNumber(string $number)    Define number
24
 * @method int getLine()    Acesso a line
25
 * @method setLine(integer $line)    Define line
26
 * @method string getAccessKey()    Acesso a accessKey
27
 * @method setAccessKey(string $accessKey)    Define accessKey
28
 * @method setShipDate(string $shipDate)    Define shipDate
29
 * @method string getUrl()    Acesso a url
30
 * @method setUrl(string $url)    Define url
31
 */
32
class Invoice extends EntityAbstract implements EntityInterface
33
{
34
    use DateTimeTrait;
35
36
    protected $primaryKey = 'number';
37
38
    /**
39
     * @codeCoverageIgnore
40
     */
41
    public function getSchema()
42
    {
43
        return [
44
            'number'    => 'string',
45
            'line'      => 'integer',
46
            'accessKey' => 'string',
47
            'issueDate' => 'datetime',
48
            'shipDate'  => 'datetime',
49
            'url'       => 'string',
50
        ];
51
    }
52
53 4
    /**
54
     * {@inheritdoc}
55 4
     */
56 4
    protected function beforeConstruct($data = null)
57
    {
58 4
        if (is_array($data) && array_key_exists('date', $data)) {
59
            $data['issueDate'] = $data['date'];
60
        }
61 2
62
        return $data;
63 2
    }
64
65
    public function check()
66 1
    {
67
        $this->setRequiredSchema(['number', 'line', 'accessKey', 'issueDate']);
68 1
        $this->setOptionalSchema(['shipDate', 'url']);
69
70
        return $this->isValid();
71
    }
72
73
    public function getIssueDate()
74
    {
75
        return $this->dateGet('issueDate');
76
    }
77
78
    public function getShipDate()
79
    {
80
        return $this->dateGet('shipDate');
81
    }
82
}
83