summaryrefslogtreecommitdiff
path: root/tests/functional/TestStorage.php
blob: ff8512abf55a107b683b33544e3bd594d5294eae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php


namespace tests\functional;

use kch42\ste\StorageAccess;

class TestStorage implements StorageAccess
{
    /** @var string */
    private $dir;

    public function __construct(string $dir)
    {
        $this->dir = $dir;
    }

    public function load(string $tpl, string &$mode)
    {
        $mode = StorageAccess::MODE_SOURCE;
        return file_get_contents($this->dir . DIRECTORY_SEPARATOR . $tpl);
    }

    public function save(string $tpl, string $data, $mode): void
    {
        if ($mode != StorageAccess::MODE_TRANSCOMPILED) {
            return;
        }

        file_put_contents($this->dir . DIRECTORY_SEPARATOR . "$tpl.transc.php", $data);
    }
}