bytic /
data-objects
| 1 | <?php |
||
| 2 | |||
| 3 | namespace ByTIC\DataObjects; |
||
| 4 | |||
| 5 | use ByTIC\DataObjects\Utility\Constants; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Class AbstractDto |
||
| 9 | * @package ByTIC\DataObjects |
||
| 10 | */ |
||
| 11 | abstract class AbstractDto implements \ArrayAccess |
||
| 12 | { |
||
| 13 | 1 | use Behaviors\ArrayAccess\ArrayAccessTrait; |
|
| 14 | 1 | use Behaviors\PropertyOverloading\PropertyOverloadingTrait; |
|
| 15 | 1 | use Behaviors\Accessors\AccessorsTrait; |
|
| 16 | |||
| 17 | /** |
||
| 18 | * @param $name |
||
| 19 | * @param null $default |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 20 | * @return mixed|void |
||
| 21 | */ |
||
| 22 | 13 | public function get($name, $default = null) |
|
| 23 | { |
||
| 24 | 13 | $return = $this->callAccessors('get', $name); |
|
| 25 | 13 | if (is_string($return) && $return == Constants::NO_ACCESSORS_FOUND) { |
|
| 26 | 6 | return $this->transformValue($name, $this->getPropertyValue($name, $default)); |
|
| 27 | } |
||
| 28 | 7 | return $return; |
|
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @param $name |
||
| 33 | * @param $value |
||
| 34 | * @return mixed |
||
| 35 | */ |
||
| 36 | 16 | public function set($name, $value) |
|
| 37 | { |
||
| 38 | 16 | $return = $this->callAccessors('set', $name, [$value]); |
|
| 39 | 16 | if (is_string($return) && $return == Constants::NO_ACCESSORS_FOUND) { |
|
| 40 | 10 | return $this->setPropertyValue($name, $value); |
|
| 41 | } |
||
| 42 | 9 | return $return; |
|
| 43 | } |
||
| 44 | } |
||
| 45 |