Passed
Push — master ( 750782...7d3f93 )
by Sam
01:54
created

StringIterator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 5
dl 0
loc 38
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A isNot() 0 3 1
A is() 0 3 1
A __toString() 0 3 1
1
<?php
2
3
namespace Badcow\DNS\Parser;
4
5
class StringIterator extends \ArrayIterator
6
{
7
    /**
8
     * StringIterator constructor.
9
     *
10
     * @param string $string
11
     */
12 12
    public function __construct(string $string = '')
13
    {
14 12
        parent::__construct(str_split($string));
15 12
    }
16
17
    /**
18
     * @param string $value
19
     *
20
     * @return bool
21
     */
22 7
    public function is(string $value): bool
23
    {
24 7
        return $value === $this->current();
25
    }
26
27
    /**
28
     * @param string $value
29
     *
30
     * @return bool
31
     */
32 10
    public function isNot(string $value): bool
33
    {
34 10
        return $value !== $this->current();
35
    }
36
37
    /**
38
     * @return string
39
     */
40 3
    public function __toString()
41
    {
42 3
        return implode($this->getArrayCopy());
43
    }
44
}
45