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

Engine   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 6
c 2
b 1
f 0
lcom 1
cbo 2
dl 0
loc 62
ccs 16
cts 16
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getFilesystem() 0 4 1
A getEncoder() 0 4 1
A createDocumentStore() 0 4 1
A dropCollection() 0 4 1
A createCollection() 0 6 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