Completed
Push — master ( 74ffa0...ed410a )
by Mariano
10:21
created

AbstractBuilder::build()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
ccs 4
cts 5
cp 0.8
rs 9.6666
cc 2
eloc 5
nc 2
nop 0
crap 2.032
1
<?php
2
namespace Mcustiel\PowerRoute\Utils;
3
4
abstract class AbstractBuilder
5
{
6
    private $name;
7
    private $argument;
8
9 1
    public function withName($name)
10
    {
11 1
        $this->name = $name;
12
13 1
        return $this;
14
    }
15
16 1
    public function withArgument($argument)
17
    {
18 1
        $this->argument = $argument;
19 1
        return $this;
20
    }
21
22 1
    public function build()
23
    {
24 1
        if (empty($this->name)) {
25
            throw new \RuntimeException('Actions, Matchers and InputSources should be identified by a name');
26
        }
27
        return [
28 1
            $this->name => $this->argument
29 1
        ];
30
    }
31
}
32