Completed
Pull Request — master (#15)
by John
02:41
created

FixedTextParser::getText()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 23
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3

Importance

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