Completed
Push — master ( f8d4b2...9b5d9d )
by Márk
10s
created

CommonInfoCollector::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 2
1
<?php
2
3
namespace Nofw\Emperror\Processor;
4
5
use Nofw\Emperror\Processor;
6
use Nofw\Error\Context;
7
8
/**
9
 * Collects common application info about the host.
10
 *
11
 * @author Márk Sági-Kazár <[email protected]>
12
 */
13
final class CommonInfoCollector implements Processor
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function process(\Throwable $t, array $context): array
19
    {
20
        $common = [
21
            Context::APP => [
22
                'os' => php_uname(),
23
                'language' => 'PHP '.phpversion(),
24
            ],
25
        ];
26
27
        if (($hostname = gethostname()) !== false) {
28
            $common[Context::APP]['hostname'] = $hostname;
29
        }
30
31
        return array_replace_recursive($common, $context);
32
    }
33
}
34