Any::castFromLine()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
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