GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( ed0b0b...743916 )
by Gilmar
21:41
created

Manager   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 94.74%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 0
loc 63
ccs 18
cts 19
cp 0.9474
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A saveStatus() 0 9 1
A move() 0 10 2
A fetchQueue() 0 4 1
A moveToSent() 0 4 1
A moveToDelivered() 0 4 1
A moveToCanceled() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of gpupo/cnova-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 <https://opensource.gpupo.com/>.
13
 */
14
15
namespace Gpupo\CnovaSdk\Entity\Order;
16
17
use Gpupo\CnovaSdk\Entity\ManagerAbstract;
18
use Gpupo\CnovaSdk\Entity\Order\Trackings\Tracking\Tracking;
19
20
class Manager extends ManagerAbstract
21
{
22
    protected $entity = 'Order';
23
24
    protected $maps = [
25
        'saveStatus' => ['POST', '/orders/{itemId}/trackings/{status}'],
26
        'findById'   => ['GET', '/orders/{itemId}'],
27
        'fetch'      => ['GET', '/orders/status/{status}/?_offset={offset}&_limit={limit}'],
28
    ];
29
30 6
    protected function saveStatus(Order $order, $json)
31
    {
32 6
        $status = $order->getStatus();
33
34 6
        return $this->execute($this->factoryMap(
35 6
            'saveStatus',
36 6
            ['itemId' => $order->getId(), 'status' => $status]
37 6
        ), $json);
38
    }
39
40 8
    protected function move($statusTo, Order $order, Tracking $tracking)
41
    {
42 8
        if (in_array($statusTo, ['sent', 'delivered', 'cancel'], true)) {
43 8
            $order->setStatus($statusTo);
44
45 8
            return $this->saveStatus($order, $tracking->toJson());
46
        }
47
48
        return false;
49
    }
50
51
    /**
52
     * Obtém a lista de pedidos recém aprovados e que esperam processamento.
53
     */
54 1
    public function fetchQueue($offset = 0, $limit = 50, array $parameters = [])
55
    {
56 1
        return $this->fetch($offset, $limit, array_merge(['status' => 'approved'], $parameters));
57
    }
58
59
    /**
60
     * Registra uma nova operação de tracking de Envio para os itens do pedido.
61
     */
62 4
    public function moveToSent(Order $order, Tracking $tracking)
63
    {
64 4
        return $this->move('sent', $order, $tracking);
65
    }
66
67
    /**
68
     * Registra uma nova operação de tracking de Entrega para os itens do pedido.
69
     */
70 2
    public function moveToDelivered(Order $order, Tracking $tracking)
71
    {
72 2
        return $this->move('delivered', $order, $tracking);
73
    }
74
75
    /**
76
     * Registra uma nova operação de tracking de Entrega para os itens do pedido.
77
     */
78 2
    public function moveToCanceled(Order $order, Tracking $tracking)
79
    {
80 2
        return $this->move('cancel', $order, $tracking);
81
    }
82
}
83