Completed
Push — refactor-04-parser-tests ( 553ee6...bce951 )
by John
03:05 queued 47s
created

FieldParserDateOffset::getDateTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 10
ccs 0
cts 7
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Graze\CiffRenderer\Parser\FieldParser;
4
5
use Graze\CiffRenderer\Parser\FieldParser\AbstractFieldParserDate;
6
use Graze\CiffRenderer\Parser\FieldParser\FieldParserInterface;
7
8
class FieldParserDateOffset extends AbstractFieldParserDate implements FieldParserInterface
9
{
10
    /**
11
     * @return \DateTimeInterface
12
     */
13
    protected function getDateTime()
14
    {
15
        $offsetFieldName = (string) $this->xmlField->Data->Object->OffsetDate['SrcOffset'];
0 ignored issues
show
Bug introduced by
Accessing Data on the interface Graze\CiffRenderer\Simpl...mpleXmlElementInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
16
        $offsetField = $this->xmlHeader->xpath('//DateOffset[@Name="'. $offsetFieldName .'"]')[0];
0 ignored issues
show
Bug introduced by
The method xpath() does not exist on Graze\CiffRenderer\Simpl...mpleXmlElementInterface. It seems like you code against a sub-type of Graze\CiffRenderer\Simpl...mpleXmlElementInterface such as Graze\CiffRenderer\Simpl...lement\SimpleXmlElement. ( Ignorable by Annotation )

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

16
        $offsetField = $this->xmlHeader->/** @scrutinizer ignore-call */ xpath('//DateOffset[@Name="'. $offsetFieldName .'"]')[0];
Loading history...
17
18
        // currenty only supports offset days
19
        $offsetDays = (string) $offsetField->DefaultOffset->Day; // @codingStandardsIgnoreLine
20
        $dateInterval = new \DateInterval('P' . $offsetDays . 'D');
21
22
        return $this->dateTimeNow->add($dateInterval);
23
    }
24
}
25