FactoryAdapter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 17
ccs 8
cts 8
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A getAdapter() 0 10 4
1
<?php
2
3
namespace kalanis\kw_pedigree\Storage;
4
5
6
use kalanis\kw_pedigree\PedigreeException;
7
8
9
/**
10
 * Class FactoryAdapter
11
 * @package kalanis\kw_pedigree\Storage\File
12
 * Which adapter is correct one?
13
 */
14
class FactoryAdapter
15
{
16
    /**
17
     * @param APedigreeRecord $record
18
     * @throws PedigreeException
19
     * @return AEntryAdapter
20
     */
21 12
    public static function getAdapter(APedigreeRecord $record): AEntryAdapter
22
    {
23 12
        if ($record instanceof File\PedigreeRecord) {
24 9
            return new File\EntryAdapter();
25 3
        } elseif ($record instanceof SingleTable\PedigreeRecord) {
26 1
            return new SingleTable\EntryAdapter();
27 2
        } elseif ($record instanceof MultiTable\PedigreeItemRecord) {
28 1
            return new MultiTable\EntryAdapter();
29
        } else {
30 1
            throw new PedigreeException('Unknown record for getting mapper');
31
        }
32
    }
33
}
34