| 1 | <?php |
||
| 9 | class Property extends ReflectionProperty |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var \CodeBooth\DataTransferObject\DataTransferObject |
||
| 13 | */ |
||
| 14 | protected $dto; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Property constructor. |
||
| 18 | * |
||
| 19 | * @param \CodeBooth\DataTransferObject\DataTransferObject $object |
||
| 20 | * @param \ReflectionProperty $reflectionProperty |
||
| 21 | * |
||
| 22 | * @throws \ReflectionException |
||
| 23 | */ |
||
| 24 | public function __construct(DataTransferObject $object, ReflectionProperty $reflectionProperty) |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @param mixed $value |
||
| 33 | */ |
||
| 34 | public function value($value) |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Check if the attribute's value needs to cast. |
||
| 47 | * |
||
| 48 | * @param string $attribute |
||
| 49 | * |
||
| 50 | * @return bool |
||
| 51 | */ |
||
| 52 | protected function hasCast(string $attribute) |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Cast an attribute to a native PHP type. |
||
| 59 | * |
||
| 60 | * @param mixed $value |
||
| 61 | * |
||
| 62 | * @return mixed |
||
| 63 | */ |
||
| 64 | protected function cast($value) |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Get the type of cast for attribute. |
||
| 87 | * |
||
| 88 | * @param string $attribute |
||
| 89 | * |
||
| 90 | * @return string |
||
| 91 | */ |
||
| 92 | protected function getCastType(string $attribute) |
||
| 96 | } |
||
| 97 |