Str   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 3
1
<?php namespace nyx\console\input\formats;
2
3
/**
4
 * String Input
5
 *
6
 * @version     0.1.0
7
 * @author      Michal Chojnacki <[email protected]>
8
 * @copyright   2012-2017 Nyx Dev Team
9
 * @link        https://github.com/unyx/nyx
10
 */
11
class Str extends Argv
12
{
13
    /**
14
     * Constructs a String Input instance.
15
     *
16
     * @param   string                  $input      A string containing the arguments and options in an argv format.
17
     * @param   interfaces\Tokenizer    $tokenizer  A Tokenizer able to handle the $input string.
18
     * @param   interfaces\Parser       $parser     A Parser able to handle the tokens created by $tokenizer.
19
     */
20
    public function __construct(string $input, interfaces\Tokenizer $tokenizer = null, interfaces\Parser $parser = null)
21
    {
22
        // Unless a specific Tokenizer is given, we will instantiate a sane default.
23
        if (!isset($tokenizer)) {
24
            $tokenizer = new parsers\Str;
25
26
            // Our default Tokenizer is also a Parser, so if none was given, let's just re-use the instance.
27
            if (!isset($parser)) {
28
                $parser = $tokenizer;
29
            }
30
        }
31
32
        parent::__construct($tokenizer->tokenize($input), $parser);
33
    }
34
}
35