Passed
Push — master ( 302393...f8e643 )
by Sam
02:04
created

StringIterator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A ord() 0 3 1
A __construct() 0 3 1
A isNot() 0 3 1
A is() 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 8
    public function __construct(string $string)
13
    {
14 8
        parent::__construct(str_split($string));
15 8
    }
16
17
    /**
18
     * @return int
19
     */
20 8
    public function ord(): int
21
    {
22 8
        return ord($this->current());
23
    }
24
25
    /**
26
     * @param int $value
27
     * @return bool
28
     */
29 5
    public function is(int $value): bool
30
    {
31 5
        return $value === $this->ord();
32
    }
33
34
    /**
35
     * @param int $value
36
     * @return bool
37
     */
38 8
    public function isNot(int $value): bool
39
    {
40 8
        return $value !== $this->ord();
41
    }
42
}
43