Completed
Push — master ( 700e42...8caa47 )
by Gilmar
39:30 queued 14:31
created

AbstractManager::factoryEntityCollection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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;
15
use Gpupo\CommonSdk\Entity\ManagerInterface;
16
17
abstract class AbstractManager extends ManagerAbstract 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(), (array) $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