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

AbstractRequirement::throwException()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
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