Completed
Pull Request — master (#19)
by John
09:10 queued 04:43
created

FieldParserFixedText   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getOrientation() 0 3 1
A getFontFace() 0 3 1
A getText() 0 17 3
A getFontSize() 0 3 1
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();
0 ignored issues
show
Bug introduced by
The method getText() does not exist on Graze\CiffRenderer\Parse...er\FieldParserInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Graze\CiffRenderer\Parse...dParserGraphicPrimitive or Graze\CiffRenderer\Parse...ser\AbstractFieldParser or Graze\CiffRenderer\Parse...ieldParserStaticGraphic or Graze\CiffRenderer\Parse...dParserGraphicPrimitive or Graze\CiffRenderer\Parse...ieldParserStaticGraphic. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
                /** @scrutinizer ignore-call */ 
45
                $fieldText = $sourceField->getText();
Loading history...
45
            } else {
46
                $fieldText = (string) $object->Default; // @codingStandardsIgnoreLine
47
            }
48
49
            $text .= $fieldText;
50
        }
51
52
        return $text;
53
    }
54
}
55