Passed
Pull Request — master (#1)
by Harry
02:11
created

GroupConfig::getPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Graze\Sprout\Config;
4
5
use Graze\ConfigValidation\ConfigValidatorInterface;
6
use Graze\ConfigValidation\Validate;
7
use Respect\Validation\Validator as v;
8
9
class GroupConfig implements GroupConfigInterface
10
{
11
    const CONFIG_PATH = 'path';
12
13
    /** @var string */
14
    private $path;
15
16
    /**
17
     * SchemaConfig constructor.
18
     *
19
     * @param array $options Array of options
20
     *
21
     * @throws \Graze\ConfigValidation\Exceptions\ConfigValidationFailedException
22
     */
23
    public function __construct(array $options = [])
24
    {
25
        $options = static::getValidator()->validate($options);
26
        $this->path = $options[static::CONFIG_PATH];
27
    }
28
29
    /**
30
     * @return ConfigValidatorInterface
31
     */
32
    public static function getValidator(): ConfigValidatorInterface
33
    {
34
        return Validate::arr(false)
35
                       ->required(static::CONFIG_PATH, v::stringType());
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getPath(): string
42
    {
43
        return $this->path;
44
    }
45
}
46