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

AbstractBuilder::withName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
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