Passed
Push — master ( d7fd0c...0cd2cd )
by Sam
04:33
created

DummyResolver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isAuthority() 0 3 1
A allowsRecursion() 0 3 1
A getAnswer() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of PHP DNS Server.
5
 *
6
 * (c) Yif Swery <[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 yswery\DNS\Tests;
13
14
use yswery\DNS\RecordTypeEnum;
15
use yswery\DNS\ResourceRecord;
16
use yswery\DNS\Resolver\ResolverInterface;
17
18
class DummyResolver implements ResolverInterface
19
{
20
    public function isAuthority($domain): bool
21
    {
22
        return true;
23
    }
24
25
    public function allowsRecursion(): bool
26
    {
27
        return false;
28
    }
29
30
    /**
31
     * @param ResourceRecord[] $queries
32
     *
33
     * @return array
34
     */
35
    public function getAnswer(array $queries): array
36
    {
37
        $q = $queries[0];
38
39
        return [(new ResourceRecord())
40
            ->setName($q->getName())
41
            ->setClass($q->getClass())
42
            ->setTtl(300)
43
            ->setType(RecordTypeEnum::TYPE_OPT)
44
            ->setRdata('Some data'), ];
45
    }
46
}
47