Completed
Push — master ( da3759...8e04a1 )
by Gerrit
02:15
created

LiteralArgumentFactory   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 28
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A understandsString() 0 4 1
A understandsArray() 0 4 1
A createArgumentFromString() 0 8 3
A createArgumentFromArray() 0 4 1
1
<?php
2
/**
3
 * Copyright (C) 2018 Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 *
8
 * @license GPL-3.0
9
 *
10
 * @author Gerrit Addiks <[email protected]>
11
 */
12
13
namespace Addiks\SymfonyGenerics\Arguments\ArgumentFactory;
14
15
use Addiks\SymfonyGenerics\Arguments\ArgumentFactory\ArgumentFactory;
16
use Addiks\SymfonyGenerics\Arguments\Argument;
17
use Addiks\SymfonyGenerics\Arguments\LiteralArgument;
18
19
final class LiteralArgumentFactory implements ArgumentFactory
20
{
21
22 1
    public function understandsString(string $source): bool
23
    {
24 1
        return true;
25
    }
26
27 1
    public function understandsArray(array $source): bool
28
    {
29 1
        return true;
30
    }
31
32 1
    public function createArgumentFromString(string $source): Argument
33
    {
34 1
        if ($source[0] === '"' || $source[0] === "'") {
35 1
            $source = substr($source, 1, strlen($source) - 2);
36
        }
37
38 1
        return new LiteralArgument($source);
39
    }
40
41 1
    public function createArgumentFromArray(array $source): Argument
42
    {
43 1
        return new LiteralArgument($source);
44
    }
45
46
}
47