Completed
Pull Request — master (#51)
by Christoffer
02:02
created

AbstractWriter::printNodes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Digia\GraphQL\Language\Writer;
4
5
use Digia\GraphQL\Language\AST\Node\NodeInterface;
6
use Digia\GraphQL\Language\PrinterInterface;
7
8
abstract class AbstractWriter implements WriterInterface
9
{
10
    /**
11
     * @var PrinterInterface
12
     */
13
    protected $printer;
14
15
    /**
16
     * @inheritdoc
17
     */
18
    public function setPrinter(PrinterInterface $printer)
19
    {
20
        $this->printer = $printer;
21
        return $this;
22
    }
23
24
    /**
25
     * @param NodeInterface|null $node
26
     * @return string
27
     */
28
    protected function printNode(?NodeInterface $node): string
29
    {
30
        return null !== $node ? $this->printer->print($node) : '';
31
    }
32
33
    /**
34
     * @param array $nodes
35
     * @return array
36
     */
37
    protected function printNodes(array $nodes): array
38
    {
39
        return array_map(function ($node) {
40
            return $this->printer->print($node);
41
        }, $nodes);
42
    }
43
}
44