Completed
Push — master ( c4a49a...0cfcd8 )
by Márk
03:21
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\Context;
4
5
use Nofw\Error\Context;
6
7
/**
8
 * Collects common application info about the host.
9
 *
10
 * @author Márk Sági-Kazár <[email protected]>
11
 */
12
final class CommonInfoCollector implements Processor
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function process(\Throwable $t, array $context): array
18
    {
19
        $common = [
20
            Context::APP => [
21
                'os' => php_uname(),
22
                'language' => 'PHP ' . phpversion(),
23
            ],
24
        ];
25
26
        if (($hostname = gethostname()) !== false) {
27
            $common[Context::APP]['hostname'] = $hostname;
28
        }
29
30
        return array_replace_recursive($common, $context);
31
    }
32
}
33