Completed
Pull Request — master (#5)
by Benjamin
04:57
created

AbstractSkill::getTranslationDomain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Obblm\Core\Helper\Rule\Skill;
4
5
use Obblm\Core\Contracts\SkillInterface;
6
use Obblm\Core\Helper\Optionable;
7
use Symfony\Component\OptionsResolver\OptionsResolver;
8
9
abstract class AbstractSkill extends Optionable implements SkillInterface
10
{
11
    /** @var string */
12
    private $key;
13
    /** @var string */
14
    private $name;
15
    /** @var string */
16
    private $translationDomain;
17
    /** @var string */
18
    private $type;
19
    /** @var string */
20
    private $typeName;
21
    /** @var string */
22
    private $description;
23
24
    protected function hydrateWithOptions()
25
    {
26
        $this->key = $this->options['key'];
27
        $this->name = $this->options['name'];
28
        $this->translationDomain = $this->options['translation_domain'];
29
        $this->type = $this->options['type'];
30
        $this->typeName = $this->options['type_name'];
31
        $this->description = $this->options['description'] ?? "";
32
    }
33
34
    public function getKey(): string
35
    {
36
        return $this->key;
37
    }
38
39
    public function getName(): string
40
    {
41
        return $this->name;
42
    }
43
44
    public function getTranslationDomain(): string
45
    {
46
        return $this->translationDomain;
47
    }
48
49
    public function getType(): string
50
    {
51
        return $this->type;
52
    }
53
54
    public function getTypeName(): string
55
    {
56
        return $this->typeName;
57
    }
58
59
    public function getDescription(): string
60
    {
61
        return $this->description;
62
    }
63
64
    public function setKey(string $key): self
65
    {
66
        $this->key = $key;
67
        return $this;
68
    }
69
70
    public function setName(string $name): self
71
    {
72
        $this->name = $name;
73
        return $this;
74
    }
75
76
    public function setTranslationDomain(string $translationDomain): self
77
    {
78
        $this->translationDomain = $translationDomain;
79
        return $this;
80
    }
81
82
    public function setType(string $type): self
83
    {
84
        $this->type = $type;
85
        return $this;
86
    }
87
88
    public function setTypeName(string $typeName): self
89
    {
90
        $this->typeName = $typeName;
91
        return $this;
92
    }
93
94
    public function __toString(): string
95
    {
96
        return $this->name;
97
    }
98
99
    public function configureOptions(OptionsResolver $resolver):void
100
    {
101
        $resolver->setDefaults([
102
            'key'                => null,
103
            'type'               => null,
104
            'name'               => null,
105
            'translation_domain' => null,
106
            'type_name'          => null,
107
            'description'        => null,
108
        ])
109
            ->setRequired(['key', 'type', 'name', 'translation_domain', 'type_name'])
110
            ->setAllowedTypes('key', ['string'])
111
            ->setAllowedTypes('name', ['string'])
112
            ->setAllowedTypes('translation_domain', ['string'])
113
            ->setAllowedTypes('type', ['string'])
114
            ->setAllowedTypes('type_name', ['string'])
115
            ->setAllowedTypes('description', ['string', 'null'])
116
        ;
117
    }
118
}
119