ObjectTypeHintTrait::assertObject()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 2
crap 2
1
<?php declare(strict_types=1);
2
3
/*
4
 * This file is part of the pinepain/php-object-maps PHP library.
5
 *
6
 * Copyright (c) 2016-2017 Bogdan Padalko <[email protected]>
7
 *
8
 * Licensed under the MIT license: http://opensource.org/licenses/MIT
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code or visit http://opensource.org/licenses/MIT
12
 */
13
14
namespace Pinepain\ObjectMaps;
15
16
17
use function is_object;
18
use Pinepain\ObjectMaps\Exceptions\UnexpectedValueException;
19
20
21
trait ObjectTypeHintTrait
22
{
23 42
    protected function assertObject($value, string $name)
24
    {
25 42
        if (!is_object($value)) {
26 10
            throw new UnexpectedValueException("{$name} is not an object");
27
        }
28 34
    }
29
}
30