| Conditions | 2 |
| Paths | 2 |
| Total Lines | 29 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 22 | public function get(Identity $id, $criteria = null) |
||
| 23 | { |
||
| 24 | $it = Finder::create() |
||
| 25 | ->files() |
||
| 26 | ->name((string) $id . '-*') |
||
| 27 | ->in($this->dataPath); |
||
| 28 | |||
| 29 | $files = iterator_to_array($it); |
||
| 30 | |||
| 31 | if (empty($files)) { |
||
| 32 | throw new \Exception; |
||
| 33 | } |
||
| 34 | |||
| 35 | $match = end($files); |
||
| 36 | |||
| 37 | $time = $match->getMTime(); |
||
| 38 | $creation = new \DateTime; |
||
| 39 | $creation->setTimestamp($time); |
||
| 40 | |||
| 41 | $aggregate = unserialize(file_get_contents($match)); |
||
| 42 | |||
| 43 | $snapshot = new Snapshot( |
||
| 44 | $aggregate, |
||
| 45 | $aggregate->getVersion(), |
||
| 46 | $creation |
||
| 47 | ); |
||
| 48 | |||
| 49 | return $snapshot; |
||
| 50 | } |
||
| 51 | |||
| 67 |