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

ClosureUsePrinter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 50
ccs 10
cts 16
cp 0.625
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getType() 0 4 1
A convert() 0 12 2
1
<?php
2
3
namespace PhpToZephir\Converter\Printer\Expr;
4
5
use PhpToZephir\Logger;
6
use PhpParser\Node\Expr;
7
use PhpToZephir\ReservedWordReplacer;
8
use PhpToZephir\Converter\Dispatcher;
9
10
class ClosureUsePrinter
11
{
12
    /**
13
     * @var Dispatcher
14
     */
15
    private $dispatcher = null;
16
    /**
17
     * @var Logger
18
     */
19
    private $logger = null;
20
    /**
21
     * @var ReservedWordReplacer
22
     */
23
    private $reservedWordReplacer = null;
24
25
    /**
26
     * @param Dispatcher           $dispatcher
27
     * @param Logger               $logger
28
     * @param ReservedWordReplacer $reservedWordReplacer
29
     */
30 1
    public function __construct(Dispatcher $dispatcher, Logger $logger, ReservedWordReplacer $reservedWordReplacer)
31
    {
32 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...
33 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...
34 1
        $this->reservedWordReplacer = $reservedWordReplacer;
35 1
    }
36
37 1
    public static function getType()
38
    {
39 1
        return 'pExpr_ClosureUse';
40
    }
41
42
    /**
43
     * @param Expr\ClosureUse $node
44
     *
45
     * @return string
46
     */
47 1
    public function convert(Expr\ClosureUse $node)
48
    {
49 1
        if ($node->byRef) {
50
            $this->logger->logNode(
51
                'Zephir not support reference parameters for now. Stay tuned for https://github.com/phalcon/zephir/issues/203',
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 127 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
52
                $node,
53
                $this->dispatcher->getMetadata()->getClass()
54
            );
55
        }
56
57 1
        return $this->reservedWordReplacer->replace($node->var);
58
    }
59
}
60