Completed
Pull Request — 2.x (#216)
by Akihito
09:47
created

Code::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Compiler;
6
7
use PhpParser\Node;
8
use PhpParser\PrettyPrinter\Standard;
9
10
final class Code
11
{
12
    /**
13
     * @var bool
14
     */
15
    public $isSingleton;
16
17
    /**
18
     * @var null|IpQualifier
19
     */
20
    public $qualifiers;
21
22
    /**
23
     * @var Node
24
     */
25
    private $node;
26
27
    public function __construct(Node $node, bool $isSingleton = false, IpQualifier $qualifier = null)
28
    {
29
        $this->node = $node;
30
        $this->isSingleton = $isSingleton;
31
        $this->qualifiers = $qualifier;
32
    }
33
34
    public function __toString()
35
    {
36
        $prettyPrinter = new Standard();
37
38
        return $prettyPrinter->prettyPrintFile([$this->node]);
39
    }
40
}
41