NativeExtensions::isExtensionLoaded()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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