Passed
Push — master ( 23853d...5334ba )
by Volodymyr
08:53
created

ConfigList::__construct()   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
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * Copyright (c) 2019. Volodymyr Hryvinskyi.  All rights reserved.
4
 * @author: <mailto:[email protected]>
5
 * @github: <https://github.com/hryvinskyi>
6
 */
7
8
declare(strict_types=1);
9
10
namespace Hryvinskyi\InvisibleCaptcha\Model\Area;
11
12
use Magento\Framework\Exception\LocalizedException;
13
14
/**
15
 * Class ConfigList
16
 */
17
class ConfigList implements ConfigListInterface
18
{
19
    /**
20
     * @var ConfigInterface[]
21
     */
22
    private $list = [];
23
24
    /**
25
     * ConfigList constructor.
26
     *
27
     * @param ConfigInterface[] $list
28
     */
29
    public function __construct(array $list = [])
30
    {
31
        $this->list = $list;
32
    }
33
34
    /**
35
     * @return ConfigInterface[]
36
     */
37
    public function getConfigList(): array
38
    {
39
        return $this->list;
40
    }
41
42
    /**
43
     * @param string $area
44
     *
45
     * @return ConfigInterface
46
     * @throws LocalizedException
47
     */
48
    public function getConfig(string $area): ConfigInterface
49
    {
50
        if (!isset($this->list[$area])) {
51
            throw new LocalizedException(__('Area not found'));
52
        }
53
54
        return $this->list[$area];
55
    }
56
}
57