-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StaticProperty.php
60 lines (50 loc) · 1.19 KB
/
StaticProperty.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php declare(strict_types = 1);
/**
* StaticProperty.php
*
* @license More in LICENSE.md
* @copyright https://www.fastybird.com
* @author Adam Kadlec <adam.kadlec@fastybird.com>
* @package FastyBird:DevicesModule!
* @subpackage Entities
* @since 0.9.0
*
* @date 04.01.22
*/
namespace FastyBird\DevicesModule\Entities\Channels\Properties;
use Doctrine\ORM\Mapping as ORM;
use FastyBird\DevicesModule\Exceptions;
use FastyBird\Metadata\Types as MetadataTypes;
/**
* @ORM\Entity
*/
class StaticProperty extends Property implements IStaticProperty
{
/**
* {@inheritDoc}
*/
public function getType(): MetadataTypes\PropertyTypeType
{
return MetadataTypes\PropertyTypeType::get(MetadataTypes\PropertyTypeType::TYPE_STATIC);
}
/**
* {@inheritDoc}
*/
public function getValue()
{
if ($this->getParent() !== null) {
return $this->getParent()->getValue();
}
return parent::getValue();
}
/**
* {@inheritDoc}
*/
public function setValue(?string $value): void
{
if ($this->getParent() !== null) {
throw new Exceptions\InvalidStateException('Value setter is allowed only for parent');
}
parent::setValue($value);
}
}