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

TryCatchPrinter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 24
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 4 1
A convert() 0 8 2
1
<?php
2
3
namespace PhpToZephir\Converter\Printer\Stmt;
4
5
use PhpParser\Node\Stmt;
6
use PhpToZephir\Converter\SimplePrinter;
7
8
class TryCatchPrinter extends SimplePrinter
9
{
10
    /**
11
     * @return string
12
     */
13 1
    public static function getType()
14
    {
15 1
        return 'pStmt_TryCatch';
16
    }
17
18
    /**
19
     * @param Stmt\TryCatch $node
20
     *
21
     * @return string
22
     */
23 1
    public function convert(Stmt\TryCatch $node)
24
    {
25 1
        return 'try {'.$this->dispatcher->pStmts($node->stmts)."\n".'}'
26 1
             .$this->dispatcher->pImplode($node->catches)
27 1
             .($node->finallyStmts !== null
28 1
                ? ' finally {'.$this->dispatcher->pStmts($node->finallyStmts)."\n".'}'
29 1
                : '');
30
    }
31
}
32