1 | <?php |
||
31 | abstract class AbstractStorage implements StorageInterface |
||
32 | { |
||
33 | /** |
||
34 | * Reads versions from the storage file. |
||
35 | * |
||
36 | * @return Migrated |
||
37 | * |
||
38 | * @throws StorageException |
||
39 | */ |
||
40 | 6 | final public function fetchAll() |
|
41 | { |
||
42 | 6 | $collection = $this->doFetchAll(); |
|
43 | 6 | if (!$collection instanceof Migrated) { |
|
44 | StorageException::throwInvalidObjectException($collection, Migrated::class); |
||
45 | } |
||
46 | return $collection; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @inheritdoc |
||
51 | */ |
||
52 | final public function update(VersionInterface $version) |
||
53 | { |
||
54 | if ($version->isMigrated()) { |
||
55 | $result = $this->save($version); |
||
56 | } else { |
||
57 | $result = $this->delete($version); |
||
58 | } |
||
59 | return $result; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return Migrated |
||
64 | */ |
||
65 | abstract protected function doFetchAll(); |
||
66 | } |
||
67 |