| Total Complexity | 6 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | class DoctrineObjectStorageAdapter implements ObjectStorageAdapter |
||
| 14 | { |
||
| 15 | protected ObjectEntryRepository $objectEntryRepository; |
||
| 16 | |||
| 17 | 11 | public function __construct(ObjectEntryRepository $objectEntryRepository) |
|
| 18 | { |
||
| 19 | 11 | $this->objectEntryRepository = $objectEntryRepository; |
|
| 20 | 11 | } |
|
| 21 | |||
| 22 | /** |
||
| 23 | * {@inheritdoc} |
||
| 24 | */ |
||
| 25 | 8 | public function store(string $key, $data, DateTime $timestamp): void |
|
| 33 | 8 | } |
|
| 34 | |||
| 35 | /** |
||
| 36 | * {@inheritdoc} |
||
| 37 | */ |
||
| 38 | 9 | public function get(string $key, DateTime $timestamp) |
|
| 39 | { |
||
| 40 | 9 | $entry = $this->objectEntryRepository->findByKeyAtTime($key, $this->toUTC($timestamp)); |
|
| 41 | |||
| 42 | 9 | if (!$entry) { |
|
| 43 | 4 | throw new ObjectNotFoundException($key, $timestamp); |
|
| 44 | } |
||
| 45 | |||
| 46 | 8 | return $entry->getValue(); |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * {@inheritdoc} |
||
| 51 | */ |
||
| 52 | 7 | public function clear(): void |
|
| 53 | { |
||
| 54 | 7 | $this->objectEntryRepository->deleteAll(); |
|
| 55 | 7 | } |
|
| 56 | |||
| 57 | 10 | private function toUTC(DateTime $dateTime): DateTime |
|
| 60 | } |
||
| 61 | } |
||
| 62 |