summaryrefslogtreecommitdiff
path: root/tests/functional/TestStorage.php
blob: 976008cf64ee084d051d5ee17ca34e9674844558 (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 r7r\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);
    }
}