Completed
Pull Request — master (#19)
by John
04:27
created

FieldParserFixedText::getOrientation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Graze\CiffRenderer\Parser\FieldParser;
4
5
use Graze\CiffRenderer\Parser\FieldParser\FieldParserInterface;
6
7
class FieldParserFixedText extends AbstractFieldParser implements FieldParserInterface
8
{
9
    /**
10
     * @return float
11
     */
12
    public function getFontSize()
13
    {
14
        return (float) $this->xmlField->Text->Font->Pitch;
15
    }
16
17
    /**
18
     * @return string
19
     */
20
    public function getFontFace()
21
    {
22
        return (string) $this->xmlField->Text->Font->Face;
23
    }
24
25
    /**
26
     * @return int
27
     */
28
    public function getOrientation()
29
    {
30
        return (int) $this->xmlField->Orientation;
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    public function getText()
37
    {
38
        $text = '';
39
        foreach ($this->xmlField->Data->Object as $object) {
40
            if ($object->SrcField) { // @codingStandardsIgnoreLine
41
                // Field is a merge field, fetch text from source field
42
                $sourceFieldName = (string) $object->SrcField->attributes()->SrcFieldName; // @codingStandardsIgnoreLine
43
                $sourceField = $this->fieldParserRegistry->getParser($sourceFieldName);
44
                $fieldText = $sourceField->getText();
45
            } else {
46
                $fieldText = (string) $object->Default; // @codingStandardsIgnoreLine
47
            }
48
49
            $text .= $fieldText;
50
        }
51
52
        return $text;
53
    }
54
}
55