Passed
Push — master ( 0fe5f5...c76c09 )
by Nils
02:59
created

WebsiteUtil::extractDomains()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 8
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 15
rs 10
1
<?php
2
3
namespace Startwind\Inventorio\Util;
4
5
use Startwind\Inventorio\Collector\Application\WebServer\Apache\ApacheServerNameCollector;
6
7
abstract class WebsiteUtil
8
{
9
    public static function extractDomains(array $inventory): array
10
    {
11
        if (!array_key_exists(ApacheServerNameCollector::COLLECTION_IDENTIFIER, $inventory)
12
            || !is_array($inventory[ApacheServerNameCollector::COLLECTION_IDENTIFIER])
13
        ) return [];
14
15
        $configs = $inventory[ApacheServerNameCollector::COLLECTION_IDENTIFIER];
16
17
        $domains = [];
18
19
        foreach ($configs as $config) {
20
            $domains[] = $config[ApacheServerNameCollector::FIELD_SERVER_NAME];
21
        }
22
23
        return $domains;
24
    }
25
}