Test Failed
Push — master ( 575e5f...bb3910 )
by Hirofumi
02:01
created

JobRunnerRegistry   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 31
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 6 2
A get() 0 8 2
1
<?php
2
3
namespace Shippinno\Job\Application\Job;
4
5
use Shippinno\Job\Domain\Model\JobRunnerNotRegisteredException;
6
7
class JobRunnerRegistry
8
{
9
    /**
10
     * @var array
11
     */
12
    protected $jobRunners = [];
13
14
    /**
15
     * @param array $jobRunners
16
     */
17 3
    public function register(array $jobRunners): void
18
    {
19 3
        foreach ($jobRunners as $jobName => $jobRunner) {
20 3
            $this->jobRunners[$jobName] = $jobRunner;
21
        }
22 3
    }
23
24
    /**
25
     * @param string $jobName
26
     * @return JobRunner
27
     * @throws JobRunnerNotRegisteredException
28
     */
29 2
    public function get(string $jobName): JobRunner
30
    {
31 2
        if (!isset($this->jobRunners[$jobName])) {
32
            throw new JobRunnerNotRegisteredException($jobName);
33
        }
34
35 2
        return $this->jobRunners[$jobName];
36
    }
37
}
38