Completed
Push — master ( 342d9a...48bb38 )
by personal
03:04
created

Dumper::dump()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.2
cc 4
eloc 9
nc 8
nop 3
1
<?php
2
3
/*
4
 * (c) Jean-François Lépine <https://twitter.com/Halleck45>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Hal\Component\Token;
11
12
/**
13
 * Way to dump tokens
14
 *
15
 * @author Jean-François Lépine <https://twitter.com/Halleck45>
16
 */
17
class Dumper {
18
19
20
    /**
21
     * @param TokenCollection $tokens
22
     * @param int $start
23
     * @param int $len
24
     * @return string
25
     */
26
    public function dump(TokenCollection $tokens, $start = 0, $len = 0)
27
    {
28
        $str = '';
29
        if($len == 0) {
30
            $len = sizeof($tokens);
31
        }
32
        if($start < 0) {
33
            $start = 0;
34
        }
35
        for($i = $start; $i < $len; $i++) {
36
            $str .= sprintf("\n%s : %s", token_name($tokens[$i]->getType()), $tokens[$i]->getValue());
37
        }
38
        return $str;
39
    }
40
41
}