Value::parse()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
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
 */
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
 * @package Kocuj\Di\ArgumentParser\Value
20
 */
21
class Value implements ArgumentParserInterface
22
{
23
    /**
24
     * Service argument to parse
25
     *
26
     * @var array
27
     */
28
    private $argument;
29
30
    /**
31
     * Constructor
32
     *
33
     * @param array $argument Service argument to parse
34
     * @throws Exception
35
     */
36 18
    public function __construct(array $argument)
37
    {
38
        // remember arguments
39 18
        $this->argument = $argument;
40
        // check argument
41 18
        if (!isset($this->argument['value'])) {
42 3
            throw new Exception('No "value" argument');
43
        }
44 15
    }
45
46
    /**
47
     * Parse service argument and return argument to service constructor
48
     *
49
     * @return mixed Parsed argument
50
     * @see \Kocuj\Di\ArgumentParser\ArgumentParserInterface::parse()
51
     */
52 15
    public function parse()
53
    {
54
        // exit
55 15
        return $this->argument['value'];
56
    }
57
}
58