Passed
Push — master ( 657f5c...767802 )
by Ekin
03:11
created

Factory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 18
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 10 2
A isValidType() 0 4 1
1
<?php declare(strict_types = 1);
2
3
namespace ekinhbayar\GitAmp\Event;
4
5
class Factory
6
{
7 4
    public function build(string $namespace, array $event): Event
8
    {
9 4
        $eventType = $namespace . '\\' . $event['type'];
10
11 4
        if (!$this->isValidType($eventType)) {
12 2
            throw new UnknownEventException($event['type']);
13
        }
14
15 2
        return new $eventType($event);
16
    }
17
18 4
    private function isValidType(string $type): bool
19
    {
20 4
        return \class_exists($type);
21
    }
22
}
23