Completed
Push — master ( bc639c...51f493 )
by Gilmar
21:02
created

ManagerAbstract::fetchPrepare()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of gpupo component
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
namespace Gpupo\NetshoesSdk\Entity;
11
12
use Gpupo\CommonSdk\Entity\EntityInterface;
13
use Gpupo\CommonSdk\Entity\ManagerAbstract as CommonAbstract;
14
use Gpupo\CommonSdk\Entity\ManagerInterface;
15
16
abstract class ManagerAbstract extends CommonAbstract implements ManagerInterface
17
{
18
    protected function fetchDefaultParameters()
19
    {
20
        return [
21
        ];
22
    }
23
24
    /**
25
     * @return Gpupo\Common\Entity\CollectionAbstract|null
26
     */
27
    protected function fetchPrepare($data)
28
    {
29
        if (!empty($data)) {
30
            return $this->factoryEntityCollection($data);
31
        }
32
    }
33
34
    protected function factoryEntityCollection($data)
35
    {
36
        return $this->factoryNeighborObject($this->getEntityName() . 'Collection', $data);
37
    }
38
39
    /**
40
     * @return Gpupo\Common\Entity\CollectionAbstract|null
41
     */
42
    public function findById($itemId)
43
    {
44
        $data = parent::findById($itemId);
45
46
        if (!empty($data)) {
47
            return $this->factoryEntity($data->toArray());
48
        }
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function update(EntityInterface $entity, EntityInterface $existent)
55
    {
56
        $text = 'Chamada a Atualização de entity ' . $this->entity;
57
58
        return $this->log('debug', $text, [
59
            'entity'   => $entity,
60
            'existent' => $existent,
61
        ]);
62
    }
63
}
64