Completed
Push — master ( fd3130...674c45 )
by John
03:39
created

FieldParserStaticGraphicTest::getXmlField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 25
nc 1
nop 0
dl 0
loc 4
rs 9.52
c 0
b 0
f 0
1
<?php
2
3
namespace Graze\CiffRenderer\Test\Parser\FieldParser;
4
5
use Graze\CiffRenderer\Test\AbstractFieldParserTest;
6
use Graze\CiffRenderer\Parser\FieldParser\FieldParserStaticGraphic;
7
use \SimpleXMLElement;
8
9
class FieldParserStaticGraphicTest extends AbstractFieldParserTest
10
{
11
    /**
12
     * @var FieldParserStaticGraphic
13
     */
14
    private $parser;
15
16
    /**
17
     * @return SimpleXMLElement
18
     */
19
    protected function getXmlField()
20
    {
21
        return new SimpleXMLElement(
22
            '<Field Name="i am field name">
23
                <FldType>StaticGraphic</FldType>
24
                <CLSID>{6AE09851-D80F-11D4-8DAE-0050DAFE8A9F}</CLSID>
25
                <X>4200</X>
26
                <Y>250</Y>
27
                <W>3775</W>
28
                <H>450</H>
29
                <Ln>1</Ln>
30
                <CalcData><![CDATA[i am path to graphic]]></CalcData>
31
                <Data>
32
                    <Object>
33
                        <DataType>0</DataType>
34
                        <MaxNoOfChars>14</MaxNoOfChars>
35
                        <Default><![CDATA[i am path to graphic]]></Default>
36
                    </Object>
37
                </Data>
38
                <Graphic>
39
                    <GfxW>8500</GfxW>
40
                    <GfxH>4700</GfxH>
41
                    <StaticGfx>
42
                        <AspectRatio>0</AspectRatio>
43
                    </StaticGfx>
44
                </Graphic>
45
            </Field>'
46
        );
47
    }
48
49
    /**
50
     * @return FieldParserStaticGraphic
51
     */
52
    protected function getParser()
53
    {
54
        if (!$this->parser) {
55
            $this->parser = new FieldParserStaticGraphic();
56
        }
57
58
        return $this->parser;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->parser returns the type Graze\CiffRenderer\Parse...ieldParserStaticGraphic which is incompatible with the return type mandated by Graze\CiffRenderer\Test\...ParserTest::getParser() of Graze\CiffRenderer\Test\...er\FieldParserInterface.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
59
    }
60
61
    public function testGetGraphic()
62
    {
63
        $graphic = 'i am path to graphic';
64
        $this->assertEquals($graphic, $this->getParser()->getGraphic());
65
    }
66
}
67