# disk-usage-insights/1.8/src/Domain/SnapshotRepository.php

Disk Usage Insights, version 1.8. 35 lines.

- Page: https://pluginprobe.com/plugins/disk-usage-insights/1.8/code/src/Domain/SnapshotRepository.php
- Raw: https://pluginprobe.com/plugins/disk-usage-insights/1.8/raw/src/Domain/SnapshotRepository.php
- Modified: 2025-11-11T17:44:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/disk-usage-insights/1.8/code/src/Domain/SnapshotRepository.php#L10-L20`.

```php
<?php

namespace Mgleis\DiskUsageInsights\Domain;

use Mgleis\PhpSqliteKeyValueStore\KeyValueStore;

class SnapshotRepository {

    private KeyValueStore $kvstore;

    public function __construct(\PDO $pdo) {
        $this->kvstore = new KeyValueStore($pdo);
    }

    public function load(): Snapshot {
        $s = new Snapshot();
        $s->version = $this->kvstore->get('snapshot-version', Snapshot::CURRENT_VERSION);
        $s->root = $this->kvstore->get('snapshot-root', '');
        $s->phase = (int) $this->kvstore->get('snapshot-phase', 0);
        $s->wpcorefiles = $this->kvstore->get('snapshot-wpcorefiles', []);
        $s->collectPhaseFinished = $this->kvstore->get('snapshot-collectPhaseFinished', 0);

        return $s;
    }

    public function save(Snapshot $snapshot) {
        $this->kvstore->set('snapshot-version', $snapshot->version);
        $this->kvstore->set('snapshot-root', $snapshot->root);
        $this->kvstore->set('snapshot-phase', $snapshot->phase);
        $this->kvstore->set('snapshot-wpcorefiles', $snapshot->wpcorefiles);
        $this->kvstore->set('snapshot-collectPhaseFinished', $snapshot->collectPhaseFinished);
    }

}

```
