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

TryCatchPrinter::convert()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
crap 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