Completed
Pull Request — master (#37)
by Alberto
02:21
created

PropertyStub::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 2
dl 0
loc 14
ccs 8
cts 8
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Moka\Stub;
5
6
use Moka\Exception\InvalidArgumentException;
7
8
/**
9
 * Class PropertyStub
10
 * @package Moka\Stub
11
 */
12
class PropertyStub extends AbstractStub
13
{
14
    /**
15
     * PropertyStub constructor.
16
     * @param string $name
17
     * @param mixed $value
18
     *
19
     * @throws InvalidArgumentException
20
     */
21 10
    public function __construct(string $name, $value)
22
    {
23 10
        if (static::PREFIX_PROPERTY !== $name[0]) {
24 2
            throw new InvalidArgumentException(
25 2
                sprintf(
26 2
                    'Name must be prefixed by "%s", "%s" given',
27 2
                    StubInterface::PREFIX_PROPERTY,
28 2
                    $name
29
                )
30
            );
31
        }
32
33 8
        parent::__construct(substr($name, 1), $value);
34
    }
35
}
36