Any::castToString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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