Passed
Push — master ( 9c99b6...17c429 )
by Dāvis
03:17
created

AbstractRequirement   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A check() 0 5 4
A throwException() 0 7 2
1
<?php
2
3
namespace Sludio\HelperBundle\DependencyInjection\Requirement;
4
5
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
6
7
abstract class AbstractRequirement
8
{
9
    public function check()
10
    {
11
        foreach ($this->getRequirements() as $class => $requirement) {
12
            if (!class_exists($class) && !interface_exists($class)) {
13
                throw new InvalidConfigurationException($this->throwException());
14
            }
15
        }
16
    }
17
18
    abstract public function getRequirements();
19
20
    public function throwException(){
21
        $string = '';
22
        foreach($this->getRequirements() as $requirement){
23
            $string .= $requirement.'\n';
24
        }
25
26
        return $string;
27
    }
28
}
29