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

FieldParserFixedText   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 48
ccs 0
cts 18
cp 0
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 18 3
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