Completed
Push — master ( d8757f...fa9ad1 )
by Matteo
02:59
created

Engine::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
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 15
    public function __construct(FilesystemInterface $filesystem, EncoderInterface $encoder)
23
    {
24 15
        $this->filesystem = $filesystem;
25 15
        $this->encoder = $encoder;
26 15
    }
27
28
    /**
29
     * Get the Filesystem instance.
30
     *
31
     * @return FilesystemInterface
32
     */
33 14
    public function getFilesystem()
34
    {
35 14
        return $this->filesystem;
36
    }
37
38
39
    /**
40
     * Get the EncoderInterface instance.
41
     *
42
     * @return EncoderInterface
43
     */
44 14
    public function getEncoder()
45
    {
46 14
        return $this->encoder;
47
    }
48
49
    /**
50
     * Create a new DocumentStore.
51
     *
52
     * @param string $namespace
53
     * @return DocumentStore
54
     */
55 2
    public function createDocumentStore($namespace)
56
    {
57 2
        return new DocumentStore($this, $namespace);
58
    }
59
60 1
    public function dropCollection($collection)
61
    {
62 1
        $this->filesystem->deleteDir($collection);
63 1
    }
64
65 1
    public function createCollection($collection)
66
    {
67 1
        $this->filesystem->createDir($collection);
68
69 1
        return $this->createDocumentStore($collection);
70
    }
71
}
72