Completed
Pull Request — refactor-01-decoupling (#27)
by John
02:14
created

AbstractFieldParser::parse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 4
crap 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A AbstractFieldParser::setXmlHeader() 0 4 1
1
<?php
2
3
namespace Graze\CiffRenderer\Parser\FieldParser;
4
5
use Graze\CiffRenderer\Parser\FieldParser\FieldParserInterface;
6
use Graze\CiffRenderer\Parser\FieldParserRegistry;
7
8
abstract class AbstractFieldParser implements FieldParserInterface
9
{
10
    /**
11
     * @var \SimpleXMLElement
12
     */
13
    protected $xmlField;
14
15
    /**
16
     * @var \SimpleXMLElement
17
     */
18
    protected $xmlHeader;
19
20
    /**
21
     * @var float
22
     */
23
    protected $scale;
24
25
    /**
26
     * @var FieldParserRegistry
27
     */
28
    protected $fieldParserRegistry;
29
30
    /**
31
     * @param \SimpleXMLElement $xmlField
32
     */
33
    public function setXmlField(\SimpleXMLElement $xmlField)
34
    {
35
        $this->xmlField = $xmlField;
36 1
    }
37
38
    /**
39
     * @param \SimpleXMLElement $xmlHeader
40
     */
41
    public function setXmlHeader(\SimpleXMLElement $xmlHeader)
42 1
    {
43 1
        $this->xmlHeader = $xmlHeader;
44 1
    }
45 1
46 1
    /**
47 1
     * @param float $scale
48
     */
49
    public function setScale($scale)
50
    {
51
        $this->scale = $scale;
52
    }
53
54
    /**
55
     * @param FieldParserRegistry $fieldParserRegistry
56
     */
57
    public function setFieldParserRegistry(FieldParserRegistry $fieldParserRegistry)
58
    {
59
        $this->fieldParserRegistry = $fieldParserRegistry;
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function getFieldName()
66
    {
67
        return (string) $this->xmlField->attributes()->Name;
68
    }
69
70
    /**
71
     * @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be double?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
72
     */
73
    public function getPositionX()
74
    {
75
        return (int) $this->xmlField->X * $this->scale;
76
    }
77
78
    /**
79
     * @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be double?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
80
     */
81
    public function getPositionY()
82
    {
83
        return (int) $this->xmlField->Y * $this->scale;
84
    }
85
86
    /**
87
     * @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be double?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
88
     */
89
    public function getWidth()
90
    {
91
        return (int) $this->xmlField->W * $this->scale;
92
    }
93
94
    /**
95
     * @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be double?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
96
     */
97
    public function getHeight()
98
    {
99
        return (int) $this->xmlField->H * $this->scale;
100
    }
101
102
    /**
103
     * @return bool
104
     */
105
    public function isDisplayed()
106
    {
107
        return (string) $this->xmlField->Displayed != '0';
108
    }
109
110
    /**
111
     * @return FieldParserInterface
112
     */
113
    public static function factory()
114
    {
115
        return new static();
116
    }
117
}
118