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

StringIterator::__toString()   A

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
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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