Factory::collection()   A
last analyzed

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
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WebComplete\microDb;
4
5
class Factory
6
{
7
8
    /**
9
     * @param string $file
10
     * @param string $type
11
     *
12
     * @return StorageInterface
13
     */
14
    public function storage(string $file, string $type): StorageInterface
15
    {
16
        switch ($type) {
17
            case 'runtime':
18
                $result = new StorageRuntime($file);
19
                break;
20
            case 'file':
21
            default:
22
                $result = new StorageFile($file);
23
                break;
24
        }
25
26
        return $result;
27
    }
28
29
    /**
30
     * @param StorageInterface $storage
31
     *
32
     * @return Collection
33
     */
34
    public function collection(StorageInterface $storage): Collection
35
    {
36
        return new Collection($storage);
37
    }
38
}
39