| 1: | <?php declare(strict_types=1); |
| 2: | |
| 3: | namespace Salient\Core\Concern; |
| 4: | |
| 5: | use Salient\Contract\Core\Entity\Extensible; |
| 6: | use Salient\Core\Internal\ReadPropertyTrait; |
| 7: | use Salient\Core\Internal\WritePropertyTrait; |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | trait ExtensibleTrait |
| 15: | { |
| 16: | use ReadPropertyTrait; |
| 17: | use WritePropertyTrait; |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | protected $MetaProperties = []; |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | |
| 35: | protected $MetaPropertyNames = []; |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | public static function getDynamicPropertiesProperty(): string |
| 41: | { |
| 42: | return 'MetaProperties'; |
| 43: | } |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | public static function getDynamicPropertyNamesProperty(): string |
| 49: | { |
| 50: | return 'MetaPropertyNames'; |
| 51: | } |
| 52: | |
| 53: | |
| 54: | |
| 55: | |
| 56: | public function setDynamicProperties(array $values): void |
| 57: | { |
| 58: | $this->MetaProperties = []; |
| 59: | $this->MetaPropertyNames = []; |
| 60: | |
| 61: | foreach ($values as $name => $value) { |
| 62: | $this->__set($name, $value); |
| 63: | } |
| 64: | } |
| 65: | |
| 66: | |
| 67: | |
| 68: | |
| 69: | public function getDynamicProperties(): array |
| 70: | { |
| 71: | foreach ($this->MetaProperties as $name => $value) { |
| 72: | $properties[$this->MetaPropertyNames[$name]] = $value; |
| 73: | } |
| 74: | return $properties ?? []; |
| 75: | } |
| 76: | } |
| 77: | |