Completed
Pull Request — master (#18)
by John
03:38
created

ParserFixedText   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 53
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getFontSize() 0 4 1
A getFontFace() 0 4 1
A getOrientation() 0 4 1
A getText() 0 23 3
1
<?php
2
3
namespace Graze\CiffRenderer\Field\Parser;
4
5
class ParserFixedText extends AbstractParser
6
{
7
    /**
8
     * @return float
9
     */
10
    public function getFontSize()
11
    {
12
        return (float) $this->xmlField->Text->Font->Pitch;
13
    }
14
15
    /**
16
     * @return string
17
     */
18
    public function getFontFace()
19
    {
20
        return (string) $this->xmlField->Text->Font->Face;
21
    }
22
23
    /**
24
     * @return int
25
     */
26
    public function getOrientation()
27
    {
28
        return (int) $this->xmlField->Orientation;
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function getText()
35
    {
36
        $text = '';
37
38
        foreach ($this->xmlField->Data->Object as $object) {
39
            // @codingStandardsIgnoreStart
40
            if ($object->SrcField) {
41
                // Field is a merge field, fetch text from source field
42
                $sourceFieldName = (string) $object->SrcField->attributes()->SrcFieldName;
43
44
                $sourceField = $this->getParserManager()->getParser($sourceFieldName);
45
46
                $fieldText = $sourceField->getText();
47
            } else {
48
                $fieldText = (string) $object->Default;
49
            }
50
            // @codingStandardsIgnoreEnd
51
52
            $text .= $fieldText;
53
        }
54
55
        return $text;
56
    }
57
}
58