Passed
Push — trunk ( e9f7c7...84d40d )
by Christian
13:42 queued 12s
created

MockSnippetFile::getPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\System\Test\Snippet\Mock;
4
5
use Shopware\Core\System\Snippet\Files\AbstractSnippetFile;
6
7
/**
8
 * @internal
9
 */
10
class MockSnippetFile extends AbstractSnippetFile
11
{
12
    private string $name;
13
14
    private bool $isBase;
15
16
    private string $iso;
17
18
    private string $technicalName;
19
20
    public function __construct(string $name, ?string $iso = null, string $content = '{}', bool $isBase = true, string $technicalName = 'mock')
21
    {
22
        $this->name = $name;
23
        $this->iso = $iso ?? $name;
24
        $this->isBase = $isBase;
25
        file_put_contents($this->getPath(), $content);
26
        $this->technicalName = $technicalName;
27
    }
28
29
    public static function cleanup(): void
30
    {
31
        foreach (glob(__DIR__ . '/_fixtures/*.json') ?: [] as $mockFile) {
32
            unlink($mockFile);
33
        }
34
    }
35
36
    public function getName(): string
37
    {
38
        return $this->name;
39
    }
40
41
    public function getPath(): string
42
    {
43
        return sprintf('%s/_fixtures/%s.json', __DIR__, $this->getName());
44
    }
45
46
    public function getIso(): string
47
    {
48
        return $this->iso;
49
    }
50
51
    public function getAuthor(): string
52
    {
53
        return $this->name;
54
    }
55
56
    public function isBase(): bool
57
    {
58
        return $this->isBase;
59
    }
60
61
    public function getTechnicalName(): string
62
    {
63
        return $this->technicalName;
64
    }
65
}
66