Passed
Push — master ( 02a778...9f9faf )
by Sebastian
06:11
created

YearRenderer::parseDateRange()   B

Complexity

Conditions 7
Paths 19

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 7

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 7
eloc 11
c 1
b 0
f 0
nc 19
nop 4
dl 0
loc 17
ccs 12
cts 12
cp 1
crap 7
rs 8.8333
1
<?php
2
/*
1 ignored issue
show
Coding Style introduced by
You must use "/**" style comments for a file comment
Loading history...
3
 * citeproc-php: DateRangeYearParser.php
4
 * User: Sebastian Böttger <[email protected]>
5
 * created at 03.11.19, 20:01
6
 */
7
8
namespace Seboettg\CiteProc\Rendering\Date\DateRange;
9
10
use Seboettg\CiteProc\Rendering\Date\DatePart;
11
use Seboettg\CiteProc\Rendering\Date\DateTime;
12
use Seboettg\Collection\ArrayList;
13
14
/**
15
 * Class DateRangeYearRenderer
16
 * @package Seboettg\CiteProc\Rendering\Date
1 ignored issue
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
17
 */
4 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
18
class YearRenderer extends DateRangeRenderer
19
{
20
21
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
22
     * @param ArrayList<DatePart> $dateParts
2 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
23
     * @param DateTime $from
3 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 12 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
24
     * @param DateTime $to
3 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 12 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
25
     * @param $delimiter
2 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
26
     * @return string
1 ignored issue
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
27
     */
28 1
    public function parseDateRange(ArrayList $dateParts, DateTime $from, DateTime $to, $delimiter)
29
    {
30 1
        $ret = "";
31 1
        foreach ($dateParts as $key => $datePart) {
32 1
            if (strpos($key, "year") !== false) {
33 1
                $ret .= $this->renderOneRangePart($datePart, $from, $to, $delimiter);
34
            }
35 1
            if (strpos($key, "month") !== false) {
36 1
                $day = !empty($d = $from->getMonth()) ? $d : "";
37 1
                $ret .= $day;
38
            }
39 1
            if (strpos($key, "day") !== false) {
40 1
                $day = !empty($d = $from->getDay()) ? $datePart->render($from, $this->parentDateObject) : "";
0 ignored issues
show
Unused Code introduced by
The assignment to $d is dead and can be removed.
Loading history...
41 1
                $ret .= $day;
42
            }
43
        }
44 1
        return $ret;
45
    }
46
}
47