Completed
Push — master ( 7c7fe3...6a7799 )
by Gilmar
03:09
created

ManagerAbstract::fetchDefaultParameters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
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
            'status'     => '',
22
            'createdAt'  => '',
23
            'purchaseAt' => '',
24
        ];
25
    }
26
27
    /**
28
     * @return Gpupo\Common\Entity\CollectionAbstract|null
29
     */
30
    protected function fetchPrepare($data)
31
    {
32
        if ( ! empty($data)) {
33
            return $this->factoryEntityCollection($data);
34
        }
35
    }
36
37
    protected function factoryEntityCollection($data)
38
    {
39
        return $this->factoryNeighborObject($this->getEntityName() . 'Collection', $data);
40
    }
41
42
    /**
43
     * @return Gpupo\Common\Entity\CollectionAbstract|null
44
     */
45
    public function findById($itemId)
46
    {
47
        $data = parent::findById($itemId);
48
49
        if ( ! empty($data)) {
50
            return $this->factoryEntity($data->toArray());
51
        }
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function update(EntityInterface $entity, EntityInterface $existent)
58
    {
59
        $text = 'Chamada a Atualização de entity ' . $this->entity;
60
61
        return $this->log('debug', $text, [
62
            'entity'   => $entity,
63
            'existent' => $existent,
64
        ]);
65
    }
66
}
67