PHPClassWriter::write()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 13
loc 13
ccs 0
cts 11
cp 0
rs 9.4285
c 0
b 0
f 0
nc 2
cc 2
eloc 9
nop 1
crap 6
1
<?php
2
namespace GoetasWebservices\Xsd\XsdToPhp\Writer;
3
4
use GoetasWebservices\Xsd\XsdToPhp\Php\PathGenerator\PathGenerator;
5
use Psr\Log\LoggerAwareInterface;
6
use Psr\Log\LoggerAwareTrait;
7
use Psr\Log\LoggerInterface;
8
use Psr\Log\NullLogger;
9
use Zend\Code\Generator\FileGenerator;
10
11
class PHPClassWriter implements LoggerAwareInterface
12
{
13
    use LoggerAwareTrait;
14
15
    protected $pathGenerator;
16
17
    public function __construct(PathGenerator $pathGenerator, LoggerInterface $logger = null)
18
    {
19
        $this->pathGenerator = $pathGenerator;
20
        $this->logger = $logger ?: new NullLogger();
21
    }
22
23 View Code Duplication
    public function write(array $items)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
    {
25
        foreach ($items as $item) {
26
            $path = $this->pathGenerator->getPath($item);
27
28
            $fileGen = new FileGenerator();
29
            $fileGen->setFilename($path);
30
            $fileGen->setClass($item);
31
            $fileGen->write();
32
            $this->logger->debug(sprintf("Written PHP class file %s", $path));
33
        }
34
        $this->logger->info(sprintf("Written %s STUB classes", count($items)));
35
    }
36
}
37