Test Failed
Push — master ( 7d30ec...97ddd4 )
by Hirofumi
02:25
created

JobRunnerRegistry::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
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 1
    public function register(array $jobRunners): void
18
    {
19 1
        foreach ($jobRunners as $jobName => $jobRunner) {
20 1
            $this->jobRunners[$jobName] = $jobRunner;
21
        }
22 1
    }
23
24
    /**
25
     * @param string $jobName
26
     * @return JobRunner
27
     * @throws JobRunnerNotRegisteredException
28
     */
29
    public function get(string $jobName): JobRunner
30
    {
31
        if (!isset($this->jobRunners[$jobName])) {
32
            throw new JobRunnerNotRegisteredException($jobName);
33
        }
34
35
        return $this->jobRunners[$jobName];
36
    }
37
}
38