Completed
Push — master ( 7f3ed3...4200af )
by Gilmar
22:41
created

Status   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 45
rs 10
c 0
b 0
f 0
ccs 6
cts 12
cp 0.5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getSchema() 0 10 1
A getMessage() 0 10 2
A isPending() 0 4 1
A toLog() 0 12 3
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 <https://www.gpupo.com/>.
13
 */
14
15
namespace Gpupo\NetshoesSdk\Entity\Product;
16
17
use Gpupo\CommonSdk\Entity\EntityAbstract;
18
use Gpupo\CommonSdk\Entity\EntityInterface;
19
use Gpupo\CommonSdk\Exception\RuntimeException;
20
21
final class Status extends EntityAbstract implements EntityInterface
22
{
23
    /**
24
     * @codeCoverageIgnore
25
     */
26
    public function getSchema()
27
    {
28
        return [
29
            'active'          => 'boolean',
30
            'skuSynchronized' => 'boolean',
31
            'statusMatch'     => 'string',
32
            'hasPrice'        => 'boolean',
33
            'hasStock'        => 'boolean',
34
        ];
35
    }
36
37 1
    public function getMessage()
38
    {
39 1
        $statusMatch = $this->get('statusMatch');
40
41 1
        if (empty($statusMatch)) {
42
            throw new RuntimeException('Product Not Found', 404);
43
        }
44
45 1
        return $statusMatch;
46
    }
47
48 1
    public function isPending()
49
    {
50 1
        return 'PROCESSADO_INTEGRACAO_CATALOGO' !== $this->getMessage();
51
    }
52
53
    public function toLog()
54
    {
55
        $array = [
56
            'message' => $this->getMessage(),
57
        ];
58
59
        foreach (['getActive', 'getHasPrice', 'getHasStock', 'isPending'] as $k) {
60
            $array[$k] = (true === $this->$k()) ? 'yes' : 'no';
61
        }
62
63
        return $array;
64
    }
65
}
66