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

WebsiteUtil   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A extractDomains() 0 15 4
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
}