StringIterator::is()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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