ConfigFactory::fromArray()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
ccs 8
cts 8
cp 1
cc 4
nc 8
nop 1
crap 4
1
<?php
2
3
namespace PhpGitHooks\Module\Configuration\Service;
4
5
use PhpGitHooks\Module\Configuration\Domain\Config;
6
7
class ConfigFactory
8
{
9
    /**
10
     * @param array $data
11
     *
12
     * @return Config
13
     */
14 2
    public static function fromArray(array $data)
15
    {
16 2
        $preCommit = false === array_key_exists('pre-commit', $data) ?
17 2
            PreCommitFactory::setUndefined() : PreCommitFactory::fromArray($data['pre-commit']);
18 2
        $commitMsg = false === array_key_exists('commit-msg', $data) ?
19 2
            CommitMsgFactory::setUndefined() : CommitMsgFactory::fromArray($data['commit-msg']);
20 2
        $prePush = false === array_key_exists('pre-push', $data) ?
21 2
            PrePushFactory::setUndefined() : PrePushFactory::fromArray($data['pre-push']);
22
23 2
        return new Config($preCommit, $commitMsg, $prePush);
24
    }
25
}
26