Total Complexity | 10 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
15 | class StackableResolver implements ResolverInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var ResolverInterface[] |
||
19 | */ |
||
20 | protected $resolvers; |
||
21 | |||
22 | public function __construct(array $resolvers = []) |
||
23 | { |
||
24 | $this->resolvers = $resolvers; |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * @param ResourceRecord[] $question |
||
29 | * |
||
30 | * @return array |
||
31 | */ |
||
32 | public function getAnswer(array $question): array |
||
33 | { |
||
34 | foreach ($this->resolvers as $resolver) { |
||
35 | $answer = $resolver->getAnswer($question); |
||
36 | if (!empty($answer)) { |
||
37 | return $answer; |
||
38 | } |
||
39 | } |
||
40 | |||
41 | return []; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Check if any of the resolvers supports recursion. |
||
46 | * |
||
47 | * @return bool true if any resolver supports recursion |
||
48 | */ |
||
49 | public function allowsRecursion(): bool |
||
50 | { |
||
51 | foreach ($this->resolvers as $resolver) { |
||
52 | if ($resolver->allowsRecursion()) { |
||
53 | return true; |
||
54 | } |
||
55 | } |
||
56 | |||
57 | return false; |
||
58 | } |
||
59 | |||
60 | /* |
||
61 | * Check if any resolver knows about a domain |
||
62 | * |
||
63 | * @param string $domain the domain to check for |
||
64 | * @return boolean true if some resolver holds info about $domain |
||
65 | */ |
||
66 | public function isAuthority($domain): bool |
||
75 | } |
||
76 | } |
||
77 |