Completed
Pull Request — master (#41)
by Lars
01:31
created

KeepOriginalValuePrinter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A pStmts() 0 4 1
A pScalar_String() 0 12 1
1
<?php
2
3
namespace Spatie\Php7to5\PhpParser;
4
5
use PhpParser\Node;
6
use PhpParser\PrettyPrinter\Standard;
7
8
class KeepOriginalValuePrinter extends Standard
9
{
10
    /**
11
     * Pretty prints an array of nodes (statements) and indents them optionally.
12
     *
13
     * @param Node[] $nodes Array of nodes
14
     * @param bool $indent Whether to indent the printed nodes
15
     *
16
     * @return string Pretty printed statements
17
     */
18
    protected function pStmts(array $nodes, bool $indent = true) : string
19
    {
20
        return parent::pStmts($nodes, $indent);
21
    }
22
23
    protected function pScalar_String(Node\Scalar\String_ $node)
24
    {
25
        $str = $node->getAttribute('originalValue');
26
27
        $str = str_replace(
28
            ['"_+*-7-to-5-*+_', '_+*-7-to-5-*+_"', '_+*-7-to-5-*+_'],
29
            ['"', '"', ''],
30
            $str
31
        );
32
33
        return $str;
34
    }
35
}
36