Failed Conditions
Push — master ( ecccd5...ae55c7 )
by Marco
33s
created

ObjectType   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 6
dl 0
loc 25
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A describe() 0 7 2
A validate() 0 3 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Annotations\Type;
6
7
use function is_object;
8
9
/**
10
 * @internal
11
 */
12
class ObjectType implements Type
13
{
14
    /** @var string|null */
15
    private $className;
16
17 332
    public function __construct(?string $className)
18
    {
19 332
        $this->className = $className;
20 332
    }
21
22 33
    public function describe() : string
23
    {
24 33
        if ($this->className === null) {
25 1
            return 'object';
26
        }
27
28 33
        return $this->className;
29
    }
30
31
    /**
32
     * @param mixed $value
33
     */
34 137
    public function validate($value) : bool
35
    {
36 137
        return is_object($value) && ($this->className === null || $value instanceof $this->className);
37
    }
38
}
39