Passed
Push — master ( c437ac...1d79be )
by Aleksei
09:50 queued 07:46
created

FromFileSchemaProvider::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Cycle\Schema\Provider;
6
7
use Yiisoft\Aliases\Aliases;
8
use Yiisoft\Yii\Cycle\Schema\SchemaProviderInterface;
9
10
/**
11
 * Be careful, using this class may be insecure.
12
 */
13
final class FromFileSchemaProvider implements SchemaProviderInterface
14
{
15
    private string $file = '';
16
    private Aliases $aliases;
17
18
    public function __construct(Aliases $aliases)
19
    {
20
        $this->aliases = $aliases;
21
    }
22
23
    public function withConfig(array $config): SchemaProviderInterface
24
    {
25
        $clone = clone $this;
26
        // required option
27
        $clone->file = $this->aliases->get($config['file']);
28
        return $clone;
29
    }
30
31
    public function read(): ?array
32
    {
33
        if (!is_file($this->file)) {
34
            return null;
35
        }
36
        return include $this->file;
37
    }
38
39
    public function write($schema): bool
40
    {
41
        return false;
42
    }
43
44
    public function clear(): bool
45
    {
46
        return false;
47
    }
48
49
    public function isWritable(): bool
50
    {
51
        return false;
52
    }
53
54
    public function isReadable(): bool
55
    {
56
        return true;
57
    }
58
}
59