YamlResolver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
c 1
b 0
f 1
dl 0
loc 18
ccs 6
cts 6
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
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\Resolver;
13
14
use Symfony\Component\Yaml\Yaml;
15
use yswery\DNS\UnsupportedTypeException;
16
17
/**
18
 * Store dns records in yaml files.
19
 */
20
class YamlResolver extends JsonResolver
21
{
22
    /**
23
     * YamlResolver constructor.
24
     *
25
     * @param array $files
26
     * @param int   $defaultTtl
27
     *
28
     * @throws UnsupportedTypeException
29
     */
30 18
    public function __construct(array $files, $defaultTtl = 300)
31
    {
32 18
        parent::__construct([], $defaultTtl);
33
34 18
        foreach ($files as $file) {
35 18
            $zone = Yaml::parseFile($file);
36 18
            $resourceRecords = $this->isLegacyFormat($zone) ? $this->processLegacyZone($zone) : $this->processZone($zone);
37 18
            $this->addZone($resourceRecords);
38
        }
39 18
    }
40
}
41