1: <?php
2: namespace NGS\Patterns;
3:
4: require_once(__DIR__.'/AggregateRoot.php');
5: require_once(__DIR__.'/../Timestamp.php');
6: require_once(__DIR__.'/../Converter/PrimitiveConverter.php');
7:
8: use NGS\Converter\PrimitiveConverter;
9: use NGS\Timestamp;
10:
11: class Snapshot
12: {
13: protected $at;
14: protected $action;
15: protected $value;
16:
17: public function __construct($at, $action, AggregateRoot $value)
18: {
19: $this->at = new Timestamp($at);
20: $this->action = PrimitiveConverter::toString($action);
21: $this->value = $value;
22: }
23:
24: public function getAt()
25: {
26: return $this->at;
27: }
28:
29: public function getAction()
30: {
31: return $this->action;
32: }
33:
34: public function getValue()
35: {
36: return $this->value;
37: }
38:
39: public function __get($name)
40: {
41: if($name === 'at')
42: return $this->at;
43: if($name === 'action')
44: return $this->action;
45: if($name === 'value')
46: return $this->value;
47: throw new \InvalidArgumentException('Unknown property '.$name);
48: }
49: }
50: