mageekguy\atoum\php\tokenizer\token: lines coverage

100% of 188

OPs

100% of 39

Lines

92% of 38

Branches

91% of 23

Paths
Method OPs OPs % Lines Line % Branches Branches % Paths Path %
mageekguy\atoum\php\tokenizer\token::__construct() 27 100% 8 100% 4 75% 2 100%
mageekguy\atoum\php\tokenizer\token::__toString() 10 100% 1 100% 1 100% 1 100%
mageekguy\atoum\php\tokenizer\token::count() 5 100% 1 100% 1 100% 1 100%
mageekguy\atoum\php\tokenizer\token::getTag() 6 100% 1 100% 1 100% 1 100%
mageekguy\atoum\php\tokenizer\token::getString() 6 100% 1 100% 1 100% 1 100%
mageekguy\atoum\php\tokenizer\token::getLine() 6 100% 1 100% 1 100% 1 100%
mageekguy\atoum\php\tokenizer\token::key() 12 100% 1 100% 5 100% 2 100%
mageekguy\atoum\php\tokenizer\token::current() 12 100% 1 100% 5 100% 2 100%
mageekguy\atoum\php\tokenizer\token::rewind() 8 100% 2 100% 1 100% 1 100%
mageekguy\atoum\php\tokenizer\token::end() 8 100% 2 100% 1 100% 1 100%
mageekguy\atoum\php\tokenizer\token::valid() 7 100% 1 100% 1 100% 1 100%
mageekguy\atoum\php\tokenizer\token::next() 18 100% 5 100% 4 75% 2 50%
mageekguy\atoum\php\tokenizer\token::prev() 18 100% 5 100% 4 75% 2 50%
mageekguy\atoum\php\tokenizer\token::append() 13 100% 1 100% 1 100% 1 100%
mageekguy\atoum\php\tokenizer\token::seek() 17 100% 6 100% 5 100% 2 100%
mageekguy\atoum\php\tokenizer\token::getParent() 6 100% 1 100% 1 100% 1 100%
mageekguy\atoum\php\tokenizer\token::getValue() 9 100% 1 100% 1 100% 1 100%
#
1
<?php
2

                    
3
namespace mageekguy\atoum\php\tokenizer;
4

                    
5
use
6
	mageekguy\atoum\exceptions,
7
	mageekguy\atoum\php\tokenizer\iterator
8
;
9

                    
10
class token extends iterator\value
11
{
12
	protected $key = 0;
13
	protected $tag = '';
14
	protected $string = null;
15
	protected $line = null;
16

                    
17
	public function __construct($tag, $string = null, $line = null, iterator\value $parent = null)100%
18
	{
19
		$this->tag = $tag;
20
		$this->string = $string;
21
		$this->line = $line;
22

                    
23
		if ($parent !== null)
24
		{
25
			$this->setParent($parent);
26
		}
27
	}
28

                    
29
	public function __toString()100%
30
	{
31
		return (string) ($this->string ?: $this->tag);
32
	}
33

                    
34
	public function count()100%
35
	{
36
		return 1;
37
	}
38

                    
39
	public function getTag()100%
40
	{
41
		return $this->tag;
42
	}
43

                    
44
	public function getString()100%
45
	{
46
		return $this->string;
47
	}
48

                    
49
	public function getLine()100%
50
	{
51
		return $this->line;
52
	}
53

                    
54
	public function key()100%
55
	{
56
		return $this->key === 0 ? 0 : null;
57
	}
58

                    
59
	public function current()100%
60
	{
61
		return $this->key !== 0 ? null : $this;
62
	}
63

                    
64
	public function rewind()100%
65
	{
66
		$this->key = 0;
67

                    
68
		return $this;
69
	}
70

                    
71
	public function end()100%
72
	{
73
		$this->key = 0;
74

                    
75
		return $this;
76
	}
77

                    
78
	public function valid()100%
79
	{
80
		return ($this->key === 0);
81
	}
82

                    
83
	public function next()100%
84
	{
85
		if ($this->valid() === true)
86
		{
87
			$this->key = null;
88
		}
89

                    
90
		return $this;
91
	}
92

                    
93
	public function prev()100%
94
	{
95
		if ($this->valid() === true)
96
		{
97
			$this->key = null;
98
		}
99

                    
100
		return $this;
101
	}
102

                    
103
	public function append(iterator\value $value)100%
104
	{
105
		throw new exceptions\logic(__METHOD__ . '() is unavailable');
106
	}
107

                    
108
	public function seek($key)100%
109
	{
110
		if ($key != 0)
111
		{
112
			$this->key = null;
113
		}
114
		else
115
		{
116
			$this->key = 0;
117
		}
118

                    
119
		return $this;
120
	}
121

                    
122
	public function getParent()100%
123
	{
124
		return $this->parent;
125
	}
126

                    
127
	public function getValue()100%
128
	{
129
		return $this->getString();
130
	}
131
}