StringIterator   A
last analyzed

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 isNot() 0 3 1
A __toString() 0 3 1
A __construct() 0 3 1
A is() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of Badcow DNS Library.
5
 *
6
 * (c) Samuel Williams <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Badcow\DNS\Parser;
13
14
class StringIterator extends \ArrayIterator
15
{
16
    /**
17
     * StringIterator constructor.
18
     *
19
     * @param string $string
20
     */
21 12
    public function __construct(string $string = '')
22
    {
23 12
        parent::__construct(str_split($string));
24 12
    }
25
26
    /**
27
     * @param string $value
28
     *
29
     * @return bool
30
     */
31 9
    public function is(string $value): bool
32
    {
33 9
        return $value === $this->current();
34
    }
35
36
    /**
37
     * @param string $value
38
     *
39
     * @return bool
40
     */
41 12
    public function isNot(string $value): bool
42
    {
43 12
        return $value !== $this->current();
44
    }
45
46
    /**
47
     * @return string
48
     */
49 3
    public function __toString()
50
    {
51 3
        return implode($this->getArrayCopy());
52
    }
53
}
54