Completed
Pull Request — master (#38)
by Radosław
02:32
created

assert_object()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 1
nop 1
dl 0
loc 7
rs 10
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, string $name)
28
{
29
    require_once(__DIR__."/macros/{$ns}/{$name}.php");
30
}
31