Passed
Push — master ( 4d9c37...7cec18 )
by Dominik
13:53
created

Value::parse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
/**
4
 * Value.php
5
 *
6
 * @author Dominik Kocuj
7
 * @license https://opensource.org/licenses/MIT The MIT License
8
 * @copyright Copyright (c) 2017-2018 kocuj.pl
9
 * @package kocuj_di
10
 */
11
namespace Kocuj\Di\ArgumentParser\Value;
12
13
use Kocuj\Di\ArgumentParser\ArgumentParserInterface;
14
use Kocuj\Di\ArgumentParser\Exception;
15
16
/**
17
 * Service argument parser for value
18
 */
19
class Value implements ArgumentParserInterface
20
{
21
22
    /**
23
     * Service argument to parse
24
     *
25
     * @var array
26
     */
27
    private $argument;
28
29
    /**
30
     * Constructor
31
     *
32
     * @param array $argument
33
     *            Service argument to parse
34
     */
35 18
    public function __construct(array $argument)
36
    {
37
        // remember arguments
38 18
        $this->argument = $argument;
39
        // check argument
40 18
        if (! isset($this->argument['value'])) {
41 3
            throw new Exception('No "value" argument');
42
        }
43 15
    }
44
45
    /**
46
     * Parse service argument and return argument to service constructor
47
     *
48
     * @return mixed Parsed argument
49
     * @see \Kocuj\Di\ArgumentParser\ArgumentParserInterface::parse()
50
     */
51 15
    public function parse()
52
    {
53
        // exit
54 15
        return $this->argument['value'];
55
    }
56
}
57