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

ParamPrinter   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 53.33%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 5
dl 0
loc 32
ccs 8
cts 15
cp 0.5333
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 4 1
B convert() 0 16 6
1
<?php
2
3
namespace PhpToZephir\Converter\Printer;
4
5
use PhpParser\Node;
6
use PhpToZephir\Converter\SimplePrinter;
7
8
class ParamPrinter extends SimplePrinter
9
{
10
    /**
11
     * @return string
12
     */
13 1
    public static function getType()
14
    {
15 1
        return 'pParam';
16
    }
17
18
    /**
19
     * @param Node\Param $node
20
     *
21
     * @return string
22
     */
23 1
    public function convert(Node\Param $node)
24
    {
25 1
        if ($node->byRef) {
26
            $this->logger->logIncompatibility(
27
                'reference',
28
                'Reference not supported',
29
                $node,
30
                $this->dispatcher->getMetadata()->getClass()
31
            );
32
        }
33
34 1
        return ($node->type ? (is_string($node->type) ? $node->type : $this->dispatcher->p($node->type)).' ' : '')
35 1
             .($node->variadic ? '... ' : '')
36 1
             .''.$node->name
37 1
             .($node->default ? ' = '.$this->dispatcher->p($node->default) : '').'';
38
    }
39
}
40