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

FieldParserDateOffset   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 15
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDateTime() 0 10 1
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