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

Printer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 33
ccs 0
cts 22
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getInstance() 0 10 2
A print() 0 9 1
A dump() 0 4 1
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