Completed
Push — master ( 7e9231...419bd7 )
by Guillaume
15:48
created

TemplateManager::toArray()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 13
nc 3
nop 2
1
<?php
2
3
namespace Starkerxp\CampagneBundle\Manager;
4
5
use Starkerxp\CampagneBundle\Entity\Template;
6
use Starkerxp\StructureBundle\Entity\Entity;
7
use Starkerxp\StructureBundle\Manager\AbstractManager;
8
9
class TemplateManager extends AbstractManager
10
{
11
12
    public function getSupport(Entity $object)
13
    {
14
        return is_object($object) && $object instanceof Template;
15
    }
16
17
    public function toArray(Template $object, $fields = [])
18
    {
19
        $array = [
20
            "id"      => $object->getId(),
21
            "nom"     => $object->getNom(),
22
            "type"    => $object->getType(),
23
            "sujet"   => $object->getSujet(),
24
            "message" => $object->getMessage(),
25
        ];
26
        if(empty($fields)){
27
            return $array;
28
        }
29
        $export = [];
30
        foreach($fields as $row){
31
            $export[$row] = $array[$row];
32
        }
33
        return $export;
34
    }
35
}
36