Argument::getServiceName()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Sensorario\Container\Objects;
4
5
class Argument
6
{
7
    private $name;
8
9 13
    private function __construct(string $name)
10
    {
11 13
        $this->name = $name;
12 13
    }
13
14 13
    public static function fromString(string $name) : self
15
    {
16 13
        return new self($name);
17
    }
18
19 13
    public function isService() : bool
20
    {
21 13
        return 0 === strpos($this->name, '@');
22
    }
23
24 10
    public function getServiceName() : string
25
    {
26 10
        if ($this->isService()) {
27 5
            return str_replace('@', '', $this->name);
28
        }
29
30 9
        return $this->name;
31
    }
32
}
33