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

Dumper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A dump() 0 14 4
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
}