Psr4PathGenerator::__construct()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5.0187

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 10
cts 11
cp 0.9091
rs 9.4222
c 0
b 0
f 0
cc 5
nc 5
nop 1
crap 5.0187
1
<?php
2
namespace Goetas\Xsd\XsdToPhp\PathGenerator;
3
4
abstract class Psr4PathGenerator implements PathGenerator
5
{
6
7
    protected $namespaces = array();
8
9 10
    public function __construct(array $namespaces)
10
    {
11 10
        $this->namespaces = $namespaces;
12
13 10
        foreach ($this->namespaces as $namespace => $dir) {
14 10
            if ($namespace[strlen($namespace) - 1] !== "\\") {
15 2
                throw new PathGeneratorException("A non-empty PSR-4 prefix must end with a namespace separator, you entered '$namespace'.");
16
            }
17 8
            if (!is_dir($dir)) {
18 2
                throw new PathGeneratorException("The folder '$dir' does not exist.");
19
            }
20 6
            if (!is_writable($dir)) {
21
                throw new PathGeneratorException("The folder '$dir' is not writable.");
22
            }
23 6
        }
24 6
    }
25
}
26
27