FactoryAdapter::getAdapter()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 8
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 10
ccs 8
cts 8
cp 1
crap 4
rs 10
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