Field   A
last analyzed

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 66
    public function getSize(): int
36
    {
37 66
        return $this->size;
38
    }
39
40 66
    public function setSize(int $size): self
41
    {
42 66
        $this->size = $size;
43
44 66
        return $this;
45
    }
46
47 64
    public function getStart(): int
48
    {
49 64
        return $this->start;
50
    }
51
52 66
    public function setStart(int $start): self
53
    {
54 66
        $this->start = $start;
55
56 66
        return $this;
57
    }
58
59 68
    public function getType(): Type
60
    {
61 68
        return $this->type ?? new Any();
62
    }
63
64 70
    public function setType(Type $type): self
65
    {
66 70
        $this->type = $type;
67
68 70
        return $this;
69
    }
70
71 4
    public function getName(): string
72
    {
73 4
        return $this->name;
74
    }
75
76 68
    public function setName(string $name): self
77
    {
78 68
        $this->name = $name;
79
80 68
        return $this;
81
    }
82
83 18
    public function getContent()
84
    {
85 18
        return $this->getType()->castToString($this, $this->content);
86
    }
87
88 68
    public function setContent(string $content): self
89
    {
90 68
        $this->content = $this->getType()->castFromLine($this, $content);
91
92 64
        return $this;
93
    }
94
}
95