Completed
Push — master ( 404963...700e42 )
by Gilmar
52:42 queued 27:47
created

ManagerAbstract   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 65%

Importance

Changes 7
Bugs 0 Features 0
Metric Value
wmc 8
c 7
b 0
f 0
lcom 2
cbo 2
dl 0
loc 54
ccs 13
cts 20
cp 0.65
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A fetchDefaultParameters() 0 6 1
A factoryMap() 0 4 1
A fetchPrepare() 0 6 2
A factoryEntityCollection() 0 4 1
A findById() 0 8 2
A update() 0 9 1
1
<?php
2
3
/*
4
 * This file is part of gpupo/netshoes-sdk
5
 * Created by Gilmar Pupo <[email protected]>
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 * For more information, see <http://www.g1mr.com/>.
9
 */
10
11
namespace Gpupo\NetshoesSdk\Entity;
12
13
use Gpupo\CommonSdk\Entity\EntityInterface;
14
use Gpupo\CommonSdk\Entity\ManagerAbstract as CommonAbstract;
15
use Gpupo\CommonSdk\Entity\ManagerInterface;
16
17
abstract class ManagerAbstract extends CommonAbstract implements ManagerInterface
18
{
19 7
    protected function fetchDefaultParameters()
20
    {
21
        return [
22 7
            'buId' => 'ZT',
23
        ];
24
    }
25
26 7
    public function factoryMap($operation, array $parameters = null)
27
    {
28 7
        return parent::factoryMap($operation, array_merge($this->fetchDefaultParameters(), $parameters));
29
    }
30
31
    /**
32
     * @return Gpupo\Common\Entity\CollectionAbstract|null
33
     */
34 4
    protected function fetchPrepare($data)
35
    {
36 4
        if (!empty($data)) {
37 4
            return $this->factoryEntityCollection($data);
38
        }
39
    }
40
41 4
    protected function factoryEntityCollection($data)
42
    {
43 4
        return $this->factoryNeighborObject($this->getEntityName().'Collection', $data);
44
    }
45
46
    /**
47
     * @return Gpupo\Common\Entity\CollectionAbstract|null
48
     */
49 3
    public function findById($itemId)
50
    {
51 3
        $data = parent::findById($itemId);
52
53 3
        if (!empty($data)) {
54 3
            return $this->factoryEntity($data->toArray());
55
        }
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function update(EntityInterface $entity, EntityInterface $existent = null)
62
    {
63
        $text = 'Chamada a Atualização de entity '.$this->entity;
64
65
        return $this->log('debug', $text, [
66
            'entity'   => $entity,
67
            'existent' => $existent,
68
        ]);
69
    }
70
}
71