Passed
Push — master ( 927f67...9bd000 )
by Claudson
06:56
created

Field   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 10
eloc 21
dl 0
loc 85
ccs 25
cts 25
cp 1
rs 10
c 1
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getContent() 0 3 1
A setName() 0 5 1
A getType() 0 3 1
A getSize() 0 3 1
A setType() 0 5 1
A getName() 0 3 1
A setSize() 0 5 1
A setContent() 0 5 1
A setStart() 0 5 1
A getStart() 0 3 1
1
<?php
2
3
namespace Claudsonm\Pedi\Structure;
4
5
use Claudsonm\Pedi\Structure\Types\Any;
6
use Claudsonm\Pedi\Structure\Types\Type;
7
8
class Field
9
{
10
    /**
11
     * Indicates the number of characters/positions the information uses.
12
     */
13
    protected int $size;
14
15
    /**
16
     * Identifies the information starting position in the file.
17
     */
18
    protected int $start;
19
20
    /**
21
     * Indicates the type of information the field holds.
22
     */
23
    protected Type $type;
24
25
    /**
26
     * Identifies field name.
27
     */
28
    protected string $name = '';
29
30
    /**
31
     * The field contents.
32
     */
33
    protected $content;
34
35 51
    public function getSize(): int
36
    {
37 51
        return $this->size;
38
    }
39
40 51
    public function setSize(int $size): self
41
    {
42 51
        $this->size = $size;
43
44 51
        return $this;
45
    }
46
47 51
    public function getStart(): int
48
    {
49 51
        return $this->start;
50
    }
51
52 51
    public function setStart(int $start): self
53
    {
54 51
        $this->start = $start;
55
56 51
        return $this;
57
    }
58
59 55
    public function getType(): Type
60
    {
61 55
        return $this->type ?? new Any();
62
    }
63
64 55
    public function setType(Type $type): self
65
    {
66 55
        $this->type = $type;
67
68 55
        return $this;
69
    }
70
71 4
    public function getName(): string
72
    {
73 4
        return $this->name;
74
    }
75
76 53
    public function setName(string $name): self
77
    {
78 53
        $this->name = $name;
79
80 53
        return $this;
81
    }
82
83 8
    public function getContent()
84
    {
85 8
        return $this->getType()->castToString($this, $this->content);
86
    }
87
88 55
    public function setContent(string $content): self
89
    {
90 55
        $this->content = $this->getType()->castFromLine($this, $content);
91
92 51
        return $this;
93
    }
94
}
95