GroupConfig   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 35
ccs 0
cts 13
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPath() 0 3 1
A __construct() 0 4 1
A getValidator() 0 4 1
1
<?php
2
/**
3
 * This file is part of graze/sprout.
4
 *
5
 * Copyright © 2018 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/sprout/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/sprout
12
 */
13
14
namespace Graze\Sprout\Config;
15
16
use Graze\ConfigValidation\ConfigValidatorInterface;
17
use Graze\ConfigValidation\Validate;
18
use Respect\Validation\Validator as v;
19
20
class GroupConfig implements GroupConfigInterface
21
{
22
    const CONFIG_PATH = 'path';
23
24
    /** @var string */
25
    private $path;
26
27
    /**
28
     * SchemaConfig constructor.
29
     *
30
     * @param array $options Array of options
31
     *
32
     * @throws \Graze\ConfigValidation\Exceptions\ConfigValidationFailedException
33
     */
34
    public function __construct(array $options = [])
35
    {
36
        $options = static::getValidator()->validate($options);
37
        $this->path = $options[static::CONFIG_PATH];
38
    }
39
40
    /**
41
     * @return ConfigValidatorInterface
42
     */
43
    public static function getValidator(): ConfigValidatorInterface
44
    {
45
        return Validate::arr(false)
46
                       ->required(static::CONFIG_PATH, v::stringType());
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function getPath(): string
53
    {
54
        return $this->path;
55
    }
56
}
57