Test Failed
Push — master ( 91db11...1ff1d8 )
by Kirill
02:16
created

ObjectDefinition::instanceOf()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\Reflection\Definition;
11
12
use Railt\Reflection\Contracts\Definition\ObjectDefinition as ObjectDefinitionInterface;
13
use Railt\Reflection\Contracts\Definition\TypeDefinition;
14
use Railt\Reflection\Contracts\TypeInterface;
15
use Railt\Reflection\Definition\Behaviour\HasFields;
16
use Railt\Reflection\Definition\Behaviour\HasInterfaces;
17
use Railt\Reflection\Type;
18
use Railt\Reflection\AbstractTypeDefinition;
19
20
/**
21
 * Class ObjectDefinition
22
 */
23
class ObjectDefinition extends AbstractTypeDefinition implements ObjectDefinitionInterface
24
{
25
    use HasInterfaces;
26
    use HasFields;
27
28
    /**
29
     * @return TypeInterface
30
     */
31 1
    public static function getType(): TypeInterface
32
    {
33 1
        return Type::of(Type::OBJECT);
34
    }
35
36
    /**
37
     * @param TypeDefinition $definition
38
     * @return bool
39
     */
40 1
    public function instanceOf($definition): bool
41
    {
42
        // Return a positive response if the parent type (like Object or Interface)
43
        // can implement the desired type.
44 1
        return $this->isImplements($definition) ||
45 1
            parent::instanceOf($definition);
46
    }
47
48
    /**
49
     * @return bool
50
     */
51
    public function isRenderable(): bool
52
    {
53
        return true;
54
    }
55
56
    /**
57
     * @return bool
58
     */
59
    public function isInputable(): bool
60
    {
61
        return false;
62
    }
63
}
64