Value   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 35
rs 10
ccs 7
cts 7
cp 1
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 4 1
A __construct() 0 7 2
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