PHPWriter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 21
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A write() 0 6 1
1
<?php
2
namespace GoetasWebservices\Xsd\XsdToPhp\Writer;
3
4
use GoetasWebservices\Xsd\XsdToPhp\Php\ClassGenerator;
5
use GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPClass;
6
use Psr\Log\LoggerAwareInterface;
7
use Psr\Log\LoggerAwareTrait;
8
use Psr\Log\LoggerInterface;
9
use Psr\Log\NullLogger;
10
11
class PHPWriter extends Writer implements LoggerAwareInterface
12
{
13
    use LoggerAwareTrait;
14
15
    protected $classWriter;
16
    private $generator;
17
18
    public function __construct(PHPClassWriter $classWriter, ClassGenerator $generator, LoggerInterface $logger = null)
19
    {
20
        $this->generator = $generator;
21
        $this->classWriter = $classWriter;
22
        $this->logger = $logger ?: new NullLogger();
23
    }
24
25
    public function write(array $items)
26
    {
27
        return $this->classWriter->write(array_filter(array_map(function (PHPClass $item) {
28
            return $this->generator->generate($item);
29
        }, $items)));
30
    }
31
}
32