Resolver   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 7
c 3
b 0
f 0
lcom 1
cbo 0
dl 0
loc 41
ccs 18
cts 18
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A clear() 0 9 2
B resolve() 0 19 5
1
<?php
2
namespace Redbox\DNS;
3
4
class Resolver extends \ArrayIterator
5
{
6
7
    /**
8
     * Clear the array
9
     */
10 16
    public function clear()
11
    {
12 16
        $this->rewind();
13 16
        $num = $this->count();
14
15 16
        for ($i = 0; $i < $num; $i++) {
16 4
            $this->offsetUnset($i);
17 4
        }
18 16
    }
19
20
    /**
21
     * @param string $domain
22
     * @param int $type
23
     * @return bool
24
     */
25 16
    public function resolve($domain = '', $type = DNS_ANY)
26
    {
27 16
        if (empty($domain))
28 16
            return false;
29
30 12
        $this->clear();
31
32 12
        $result = dns_get_record($domain, $type);
33
34 12
        if (empty($result) === true || $result === false) {
35 4
            return false;
36
        }
37
38 8
        foreach ($result as $record) {
39 8
            $this->append($record);
40 8
        }
41
42 8
        return true;
43
    }
44
}