Completed
Push — master ( 282f78...6dce89 )
by Sam
05:20
created

YamlResolver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
1
<?php
2
/*
3
 * This file is part of PHP DNS Server.
4
 *
5
 * (c) Yif Swery <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace yswery\DNS\Resolver;
12
13
use Symfony\Component\Yaml\Yaml;
14
use yswery\DNS\UnsupportedTypeException;
15
16
/**
17
 * Store dns records in yaml files.
18
 */
19
class YamlResolver extends JsonResolver
20
{
21
    /**
22
     * YamlResolver constructor.
23
     *
24
     * @param array $files
25
     * @param int   $defaultTtl
26
     *
27
     * @throws UnsupportedTypeException
28
     */
29
    public function __construct(array $files, $defaultTtl = 300)
30
    {
31
        parent::__construct([], $defaultTtl);
32
33
        foreach ($files as $file) {
34
            $zone = Yaml::parseFile($file);
35
            $resourceRecords = $this->isLegacyFormat($zone) ? $this->processLegacyZone($zone) : $this->processZone($zone);
36
            $this->addZone($resourceRecords);
37
        }
38
    }
39
}
40