Completed
Push — master ( 65c91b...7e9231 )
by Guillaume
15:59
created

TemplateManager::getSupport()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.2
cc 4
eloc 6
nc 3
nop 1
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
use Symfony\Component\OptionsResolver\OptionsResolver;
9
10
class TemplateManager extends AbstractManager
11
{
12
13
    public function getSupport(Entity $object)
14
    {
15
        if (!$object instanceof Template) {
16
            return false;
17
        }
18
        if ($object->getType() == 'email' && empty($object->getMessage())) {
19
            throw new \InvalidArgumentException();
20
        }
21
22
        return $object instanceof Template;
23
    }
24
25 View Code Duplication
    public function getPostOptionResolver(OptionsResolver $resolver = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    {
27
        if (empty($resolver)) {
28
            $resolver = new OptionsResolver();
29
        }
30
        $resolver->setRequired(
31
            [
32
                'name',
33
                'type',
34
                'object',
35
                'message',
36
            ]
37
        );
38
39
        return $resolver;
40
    }
41
42
}
43