Completed
Push — master ( edf0e8...eb9261 )
by Nikola
03:47
created

Printer::dump()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace RunOpenCode\AbstractBuilder\Ast;
4
5
use PhpParser\PrettyPrinter\Standard;
6
use RunOpenCode\AbstractBuilder\Ast\Metadata\FileMetadata;
7
8
class Printer extends Standard
9
{
10
    /**
11
     * @var Printer
12
     */
13
    private static $instance;
14
15
    public static function getInstance()
16
    {
17
        if (null === self::$instance) {
18
            self::$instance = new static([
19
                'shortArraySyntax' => true
20
            ]);
21
        }
22
23
        return self::$instance;
24
    }
25
26
    public function print(FileMetadata $file)
27
    {
28
        return sprintf("
29
<?php
30
/**
31
 * This class is autogenerated by runopencode/abstract-builder library.
32
 */
33
%s\n", $this->prettyPrint($file->getAst()));
34
    }
35
36
    public function dump(FileMetadata $file)
37
    {
38
        file_put_contents($file->getFilename(), $this->print($file));
39
    }
40
}
41