| @@ 23-47 (lines=25) @@ | ||
| 20 | /** |
|
| 21 | * Class InterfaceDefinition |
|
| 22 | */ |
|
| 23 | class InterfaceDefinition extends AbstractTypeDefinition implements InterfaceDefinitionInterface |
|
| 24 | { |
|
| 25 | use HasInterfaces; |
|
| 26 | use HasFields; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * @return TypeInterface |
|
| 30 | */ |
|
| 31 | public static function getType(): TypeInterface |
|
| 32 | { |
|
| 33 | return Type::of(Type::INTERFACE); |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @param TypeDefinition $definition |
|
| 38 | * @return bool |
|
| 39 | */ |
|
| 40 | 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 | return $this->isImplements($definition) || |
|
| 45 | parent::instanceOf($definition); |
|
| 46 | } |
|
| 47 | } |
|
| 48 | ||
| @@ 23-47 (lines=25) @@ | ||
| 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 | public static function getType(): TypeInterface |
|
| 32 | { |
|
| 33 | return Type::of(Type::OBJECT); |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @param TypeDefinition $definition |
|
| 38 | * @return bool |
|
| 39 | */ |
|
| 40 | 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 | return $this->isImplements($definition) || |
|
| 45 | parent::instanceOf($definition); |
|
| 46 | } |
|
| 47 | } |
|
| 48 | ||