ConfigurationDataValidator   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 40
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 22 4
A isValidClassName() 0 4 2
1
<?php
2
/**
3
 * @author stev leibelt <[email protected]>
4
 * @since 2015-05-31 
5
 */
6
7
namespace Net\Bazzline\Component\Locator\Process\Validator;
8
9
use Net\Bazzline\Component\ProcessPipe\ExecutableException;
10
use Net\Bazzline\Component\ProcessPipe\ExecutableInterface;
11
12
class ConfigurationDataValidator implements ExecutableInterface
13
{
14
    /**
15
     * @param array $input
16
     * @return array
17
     * @throws ExecutableException
18
     */
19
    public function execute($input = null)
20
    {
21
        if (!is_array($input)) {
22
            throw new ExecutableException(
23
                'input must be an array'
24
            );
25
        }
26
27
        if (!$this->isValidClassName($input, 'assembler')) {
28
            throw new ExecutableException(
29
                'array must contain key "assembler"'
30
            );
31
        }
32
33
        if (!$this->isValidClassName($input, 'file_exists_strategy')) {
34
            throw new ExecutableException(
35
                'array must contain key "file_exists_strategy"'
36
            );
37
        }
38
39
        return $input;
40
    }
41
42
    /**
43
     * @param array $array
44
     * @param string $key
45
     * @return boolean
46
     */
47
    private function isValidClassName(array $array, $key)
48
    {
49
        return ((isset($array[$key])) && (class_exists($array[$key])));
50
    }
51
}