Any   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 6
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A castFromLine() 0 7 2
A isValidInput() 0 3 1
A castToString() 0 3 1
1
<?php
2
3
namespace Claudsonm\Pedi\Structure\Types;
4
5
use Claudsonm\Pedi\Exceptions\PediException;
6
use Claudsonm\Pedi\Structure\Field;
7
8
class Any implements Type
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13 63
    public function castFromLine(Field $field, $value)
14
    {
15 63
        if (! $this->isValidInput($value)) {
16 2
            throw PediException::invalidInput($field, str_replace("\n", '\n', $value));
17
        }
18
19 61
        return (string) $value;
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 7
    public function castToString(Field $field, $value): string
26
    {
27 7
        return (string) $value;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 65
    public function isValidInput($value): bool
34
    {
35 65
        return preg_match('/^.*$/', $value);
36
    }
37
}
38