Created
May 17, 2016 19:25
-
-
Save basz/14dd37ff055efa7e0f7acf1ba213704f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| declare(strict_types = 1); | |
| /** | |
| * @copyright Copyright (c) 2010 - 2016 bushbaby multimedia. (http://bushbaby.nl) | |
| * @author Bas Kamer <xxxx@xxxxxx> | |
| * @license Proprietary License | |
| */ | |
| namespace HF\Model\ValueObject\Structure; | |
| use HF\Model\ValueObject\Primative\NullValue; | |
| use HF\Model\ValueObject\ValueObjectInterface; | |
| class MetadataDecorator implements ValueObjectInterface | |
| { | |
| /** | |
| * @var ValueObjectInterface | |
| */ | |
| protected $content; | |
| protected $metadata; | |
| protected function __construct($content, $metadata) | |
| { | |
| $this->content = $content; | |
| $this->metadata = $metadata; | |
| } | |
| /** | |
| * @param $content | |
| * @param $metadata | |
| * @return MetadataDecorator|ValueObjectInterface | |
| */ | |
| static public function fromNative(): ValueObjectInterface | |
| { | |
| $arguments = func_get_args(); | |
| $content = $arguments[0] ?? null; | |
| $metadata = $arguments[1] ?? []; | |
| return new static($content, $metadata); | |
| } | |
| public function getContent() | |
| { | |
| return $this->content; | |
| } | |
| public function getMetadata() | |
| { | |
| return $this->metadata; | |
| } | |
| public function toArray(): array | |
| { | |
| return ['content' => $this->content->toArray(), 'metadata' => $this->getMetadata()]; | |
| } | |
| public function __call($name, $args) | |
| { | |
| return call_user_func_array([$this->content, $name], $args); | |
| } | |
| public function equals(\HF\Model\ValueObject\ValueObjectInterface $object): bool | |
| { | |
| // TODO: Implement equals() method. | |
| } | |
| public function jsonSerialize() | |
| { | |
| return $this->toArray(); | |
| } | |
| public function __toString(): string | |
| { | |
| // TODO: Implement __toString() method. | |
| return __CLASS__; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment