Completed
Push — master ( c1ba47...3b776f )
by Benjamin
10:05 queued 04:46
created

Optionable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolveOptions() 0 5 1
A __construct() 0 4 1
1
<?php
2
3
namespace Obblm\Core\Helper;
4
5
use Obblm\Core\Contracts\OptionableInterface;
6
use Symfony\Component\OptionsResolver\OptionsResolver;
7
8
abstract class Optionable implements OptionableInterface
9
{
10
    /** @var array */
11
    protected $options;
12
13
    public function __construct(array $options = [])
14
    {
15
        $this->resolveOptions($options);
16
        $this->hydrateWithOptions();
17
    }
18
19
    abstract protected function hydrateWithOptions();
20
21
    public function resolveOptions($options):void
22
    {
23
        $resolver = new OptionsResolver();
24
        $this->configureOptions($resolver);
25
        $this->options = $resolver->resolve($options);
26
    }
27
}
28