Conditions | 6 |
Paths | 8 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
26 | 2 | public function run($actual, $expected = null) |
|
27 | { |
||
28 | 2 | $dnsRecords = dns_get_record($actual); |
|
29 | 2 | $found = ''; |
|
30 | |||
31 | 2 | foreach ($dnsRecords as $dnsRecord) { |
|
32 | 2 | if (!in_array($dnsRecord['type'], $this->config['record_types'])) { |
|
33 | 2 | continue; |
|
34 | } |
||
35 | |||
36 | 2 | foreach (['mname', 'txt', 'target', 'ipv6', 'ip'] as $destination) { |
|
37 | 2 | if (array_key_exists($destination, $dnsRecord)) { |
|
38 | 2 | $found = $dnsRecord[$destination]; |
|
39 | 2 | } |
|
40 | 2 | } |
|
41 | |||
42 | 2 | if ($found === $expected) { |
|
43 | 1 | return $actual . ' has a ' . $dnsRecord['type'] . ' record that resolves to ' . $found; |
|
44 | } |
||
45 | 1 | } |
|
46 | |||
47 | 1 | throw new Result\ExpectationFailedException("Expected $actual to resolve to $expected, actually resolves to $found"); |
|
48 | } |
||
49 | } |
||
50 |
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.