Completed
Pull Request — master (#35)
by Saif Eddin
02:55 queued 38s
created

InterfacePrinter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 4
crap 1
1
<?php
2
3
namespace PhpToZephir\Converter\Printer\Stmt;
4
5
use PhpToZephir\Converter\Dispatcher;
6
use PhpToZephir\Logger;
7
use PhpParser\Node\Stmt;
8
use PhpToZephir\ReservedWordReplacer;
9
use PhpToZephir\Converter\Manipulator\ClassManipulator;
10
11
class InterfacePrinter
12
{
13
    /**
14
     * @var Dispatcher
15
     */
16
    private $dispatcher = null;
17
    /**
18
     * @var Logger
19
     */
20
    private $logger = null;
21
    /**
22
     * @var ClassManipulator
23
     */
24
    private $classManipulator = null;
25
    /**
26
     * @var ReservedWordReplacer
27
     */
28
    private $reservedWordReplacer = null;
29
30
    /**
31
     * @param Dispatcher           $dispatcher
32
     * @param Logger               $logger
33
     * @param ClassManipulator     $classManipulator
34
     * @param ReservedWordReplacer $reservedWordReplacer
35
     */
36 1
    public function __construct(
37
        Dispatcher $dispatcher,
38
        Logger $logger,
39
        ClassManipulator $classManipulator,
40
        ReservedWordReplacer $reservedWordReplacer
41
    ) {
42 1
        $this->dispatcher = $dispatcher;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 11 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
43 1
        $this->logger = $logger;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 15 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
44 1
        $this->classManipulator = $classManipulator;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
45 1
        $this->reservedWordReplacer = $reservedWordReplacer;
46 1
    }
47
48 1
    public static function getType()
49
    {
50 1
        return 'pStmt_Interface';
51
    }
52
53 4
    public function convert(Stmt\Interface_ $node)
54
    {
55 4
        $node->name = $this->reservedWordReplacer->replace($node->name);
56
57 4
        $extendsStmt = '';
58
59 4
        if (!empty($node->extends)) {
60
            $extendsStmt = ' extends ';
61
            $extends = array();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
62
            foreach ($node->extends as $extend) {
63
                $extends[] = $this->reservedWordReplacer->replace($extend);
64
            }
65
66
            $extendsStmt .= implode(', ', $extends);
67
        }
68
69 4
        return 'interface '.$node->name
70 4
             .$extendsStmt
71 4
             ."\n".'{'.$this->dispatcher->pStmts($node->stmts)."\n".'}';
72
    }
73
}
74