Completed
Push — master ( a31674...363252 )
by Radosław
36:47
created

functions.php ➔ load_macro()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

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