Completed
Branch v1.x-dev (5c2708)
by Benjamin
04:14
created

StarPlayer   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Test Coverage

Coverage 37.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
eloc 25
c 1
b 0
f 0
dl 0
loc 83
ccs 12
cts 32
cp 0.375
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A isJourneyMan() 0 3 1
A configureOptions() 0 10 1
A hydrateWithOptions() 0 5 1
A getOption() 0 6 2
A setCharacteristics() 0 4 1
A getCharacteristics() 0 3 1
A getCost() 0 3 1
A getMin() 0 3 1
A setSkills() 0 4 1
A getSkills() 0 3 1
1
<?php
2
3
namespace Obblm\Core\Helper\Rule\Inducement;
4
5
use Obblm\Core\Contracts\InducementInterface;
6
use Obblm\Core\Contracts\PositionInterface;
7
use Obblm\Core\Exception\NotFoundKeyException;
8
use Symfony\Component\OptionsResolver\OptionsResolver;
9
10
class StarPlayer extends AbstractInducement implements PositionInterface
11
{
12
    /** @var array $characteristics */
13
    protected $characteristics;
14
    /** @var array $skills */
15
    protected $skills;
16
17 1
    protected function hydrateWithOptions()
18
    {
19 1
        parent::hydrateWithOptions();
20 1
        $this->characteristics = $this->options['characteristics'];
21 1
        $this->skills = $this->options['skills'];
22 1
    }
23
24
    /**
25
     * @return array
26
     */
27
    public function getCharacteristics(): array
28
    {
29
        return $this->characteristics;
30
    }
31
32
    /**
33
     * @param array|null $characteristics
34
     * @return $this
35
     */
36
    public function setCharacteristics(?array $characteristics): self
37
    {
38
        $this->characteristics = $characteristics;
39
        return $this;
40
    }
41
42
    /**
43
     * @return array
44
     */
45
    public function getSkills(): array
46
    {
47
        return $this->skills;
48
    }
49
50
    /**
51
     * @param array|null $skills
52
     * @return $this
53
     */
54
    public function setSkills(?array $skills): self
55
    {
56
        $this->skills = $skills;
57
        return $this;
58
    }
59
60
    public function getCost(): int
61
    {
62
        return $this->getValue();
63
    }
64
65
    public function getMin(): int
66
    {
67
        return 0;
68
    }
69
70
    public function getOption(string $key)
71
    {
72
        if (!isset($this->options[$key])) {
73
            throw new NotFoundKeyException($key, 'options', self::class);
74
        }
75
        return $this->options[$key];
76
    }
77
78
    public function isJourneyMan(): bool
79
    {
80
        return false;
81
    }
82
83 1
    public function configureOptions(OptionsResolver $resolver):void
84
    {
85 1
        parent::configureOptions($resolver);
86 1
        $resolver->setDefaults([
87 1
            'characteristics' => [],
88
            'skills'          => [],
89
        ])
90 1
            ->setRequired(['characteristics'])
91 1
            ->setAllowedTypes('characteristics', ['array'])
92 1
            ->setAllowedTypes('skills', ['array'])
93
        ;
94 1
    }
95
}
96