YamlResolver::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 5
c 1
b 0
f 1
nc 3
nop 2
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 3
rs 10
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