functions.php ➔ assert_object()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 1
nop 1
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Baethon\Phln;
6
7
/**
8
 * Check if value is valid object.
9
 *
10
 * Value is considered as object if its an array
11
 * or class instance.
12
 *
13
 * @param mixed $value
14
 * @return void
15
 * @throws \Exception
16
 * @internal
17
 */
18
function assert_object($value)
19
{
20
    $type = gettype($value);
21
22
    assert(
23
        is_object($value) || is_array($value),
24
        "[{$type}] is not a valid object"
25
    );
26
}
27
28
/**
29
 * @param string $ns
30
 * @param string|string[] $name
31
 * @return void
32
 */
33
function load_macro(string $ns, $name): void
34
{
35
    $names = is_array($name)
36
        ? $name
37
        : [$name];
38
39
    foreach ($names as $filename) {
40
        require_once(__DIR__ . "/macros/{$ns}/{$filename}.php");
41
    }
42
}
43