Completed
Push — master ( 57007c...647e58 )
by Bogdan
02:16
created

AbstractContainerConfigurator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 23
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 10 3
configureMany() 0 1 ?
1
<?php
2
3
/*
4
  +----------------------------------------------------------------------+
5
  | This file is part of the pinepain/container-extras PHP library.      |
6
  |                                                                      |
7
  | Copyright (c) 2015-2016 Bogdan Padalko <[email protected]>          |
8
  |                                                                      |
9
  | Licensed under the MIT license: http://opensource.org/licenses/MIT   |
10
  |                                                                      |
11
  | For the full copyright and license information, please view the      |
12
  | LICENSE file that was distributed with this source or visit          |
13
  | http://opensource.org/licenses/MIT                                   |
14
  +----------------------------------------------------------------------+
15
*/
16
17
18
namespace Pinepain\Container\Extras;
19
20
21
use Pinepain\Container\Extras\Exceptions\InvalidConfigException;
22
use Traversable;
23
24
25
abstract class AbstractContainerConfigurator implements ContainerConfiguratorInterface
26
{
27
    /**
28
     * {@configure}
29
     */
30 15
    public function configure($config)
31
    {
32 15
        if (!is_array($config) && !($config instanceof Traversable)) {
33 1
            throw new InvalidConfigException(
34
                'You can only load definitions from an array or an object that implements Traversable interface.'
35 1
            );
36
        }
37
38 14
        $this->configureMany($config);
39 14
    }
40
41
    /**
42
     * Load configuration
43
     *
44
     * @param array|Traversable $config
45
     */
46
    abstract protected function configureMany($config);
47
}
48