Completed
Push — master ( 383c62...e08d5c )
by Matteo
02:18
created

Engine::all()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
ccs 0
cts 7
cp 0
cc 2
eloc 6
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Mattbit\Flat\Storage;
4
5
use Mattbit\Flat\Query\Parser;
6
use Mattbit\Flat\Query\Matcher;
7
use Mattbit\Flat\Document\Document;
8
use League\Flysystem\FilesystemInterface;
9
10
class Engine
11
{
12
    /**
13
     * @var FilesystemInterface
14
     */
15
    protected $filesystem;
16
17
    /**
18
     * @var EncoderInterface
19
     */
20
    protected $encoder;
21
22
    public function __construct(FilesystemInterface $filesystem, JsonEncoder $encoder)
23
    {
24
        $this->filesystem = $filesystem;
25
        $this->encoder = $encoder;
26
    }
27
28
    /**
29
     * Get the Filesystem instance.
30
     *
31
     * @return FilesystemInterface
32
     */
33
    public function getFilesystem()
34
    {
35
        return $this->filesystem;
36
    }
37
38
39
    /**
40
     * Get the EncoderInterface instance.
41
     *
42
     * @return EncoderInterface
43
     */
44
    public function getEncoder()
45
    {
46
        return $this->encoder;
47
    }
48
49
    /**
50
     * Create a new DocumentStore.
51
     *
52
     * @param string $namespace
53
     * @return DocumentStore
54
     */
55
    public function createDocumentStore($namespace)
56
    {
57
        return new DocumentStore($this, $namespace);
58
    }
59
60
    public function dropCollection($collection)
61
    {
62
        $this->filesystem->deleteDir($collection);
63
    }
64
65
    public function createCollection($collection)
66
    {
67
        $this->filesystem->createDir($collection);
68
69
        return $this->createDocumentStore($collection);
70
    }
71
}
72