Factory::getClass()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
nc 3
nop 2
dl 0
loc 10
rs 10
c 1
b 0
f 0
ccs 6
cts 6
cp 1
crap 3
1
<?php
2
3
namespace kalanis\kw_files\Processing\Storage\Dirs;
4
5
6
use kalanis\kw_files\Interfaces\IFLTranslations;
7
use kalanis\kw_storage\Interfaces;
8
9
10
/**
11
 * Class Factory
12
 * @package kalanis\kw_files\Processing\Storage\Dirs
13
 * Process dirs in storages - get correct one
14
 */
15
class Factory
16
{
17 83
    public function getClass(Interfaces\IStorage $storage, ?IFLTranslations $lang = null): ADirs
18
    {
19 83
        if ($storage instanceof Interfaces\IPassDirs) {
20 50
            if ($storage->isFlat()) {
21 23
                return new CanDirFlat($storage);
22
            } else {
23 27
                return new CanDirRecursive($storage, $lang);
24
            }
25
        } else {
26 33
            return new Basic($storage, $lang);
27
        }
28
    }
29
}
30