Completed
Branch master (3b8125)
by
unknown
01:32
created

MethodManager   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 86
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getProperty() 0 4 1
A setProperty() 0 5 1
A getClassManager() 0 4 1
A setClassManager() 0 4 1
A getPreparedName() 0 4 1
A getTemplateTags() 0 5 1
1
<?php
2
3
namespace HelloWordPl\SimpleEntityGeneratorBundle\Lib\Items;
4
5
use HelloWordPl\SimpleEntityGeneratorBundle\Lib\Interfaces\MethodInterface;
6
use HelloWordPl\SimpleEntityGeneratorBundle\Lib\Interfaces\RenderableInterface;
7
use JMS\Serializer\Annotation\Type;
8
use Symfony\Component\Validator\Constraints as Assert;
9
use HelloWordPl\SimpleEntityGeneratorBundle\Lib\Traits\TemplateTrait;
10
11
/**
12
 * Method Manager
13
 *
14
 * @author Sławomir Kania <[email protected]>
15
 */
16
abstract class MethodManager implements RenderableInterface, MethodInterface
17
{
18
    use TemplateTrait;
19
20
    /**
21
     * @Type("HelloWordPl\SimpleEntityGeneratorBundle\Lib\Items\PropertyManager")
22
     * @Assert\NotNull(message="Property for method can not be empty!")
23
     * @Assert\Valid()
24
     */
25
    private $property = null;
26
27
    /**
28
     * @Assert\NotNull(message="Method has to know about class!")
29
     * @Assert\Valid()
30
     * @var ClassManager
31
     */
32
    private $classManager = null;
33
34
    /**
35
     * Construct.
36
     *
37
     * @param ClassManager $classManager
38
     */
39
    public function __construct(ClassManager $classManager)
40
    {
41
        $this->setClassManager($classManager);
42
    }
43
44
    /**
45
     * @return PropertyManager
46
     */
47
    public function getProperty()
48
    {
49
        return $this->property;
50
    }
51
52
    /**
53
     * @param PropertyManager $property
54
     */
55
    public function setProperty(PropertyManager $property)
56
    {
57
        $this->property = $property;
58
        return $this;
59
    }
60
61
    /**
62
     * Get Base ClassManager
63
     *
64
     * @return ClassManager
65
     */
66
    public function getClassManager()
67
    {
68
        return $this->classManager;
69
    }
70
71
    /**
72
     * Set Base ClassManager
73
     *
74
     * @param ClassManager $classManager
75
     */
76
    public function setClassManager(ClassManager $classManager)
77
    {
78
        $this->classManager = $classManager;
79
    }
80
81
    /**
82
     * Return prepared method name from property eg. getNameOrSurname
83
     *
84
     * @return string
85
     */
86
    public function getPreparedName()
87
    {
88
        return ucfirst($this->getProperty()->getPreparedName());
89
    }
90
91
    /**
92
     * Return set of tags used in template
93
     *
94
     * @return array
95
     */
96
    public function getTemplateTags()
97
    {
98
        // to override
99
        return [];
100
    }
101
}
102