Factory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A collection() 0 3 1
A storage() 0 13 3
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