NativeExtensions   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 22
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigurationOption() 0 7 2
A isExtensionLoaded() 0 3 1
1
<?php
2
declare(strict_types=1);
3
namespace ZERO2TEN\Observability\APM;
4
5
use function extension_loaded;
6
use function ini_get;
7
8
/**
9
 * NativeExtensions
10
 *
11
 * @copyright Copyright (c) 2023 0TO10 B.V. <https://0to10.nl>
12
 * @package ZERO2TEN\Observability\APM
13
 */
14
trait NativeExtensions
15
{
16
    /**
17
     * @param string $name
18
     * @return bool
19
     */
20 1
    protected function isExtensionLoaded(string $name): bool
21
    {
22 1
        return extension_loaded($name);
23
    }
24
25
    /**
26
     * @param string $name
27
     * @return string|null
28
     */
29 2
    protected function getConfigurationOption(string $name): ?string
30
    {
31 2
        if (false === ($value = ini_get($name))) {
32 1
            return null;
33
        }
34
35 1
        return $value;
36
    }
37
}
38