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

TemplateManager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 27
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSupport() 0 4 2
A toArray() 0 18 3
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