DayRenderer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 19
rs 10
c 1
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A parseDateRange() 0 16 4
1
<?php
2
declare(strict_types=1);
3
/*
4
 * @link        http://github.com/seboettg/citeproc-php for the source repository
5
 * @copyright   Copyright (c) 2019 Sebastian Böttger.
6
 * @license     https://opensource.org/licenses/MIT
7
 */
8
9
namespace Seboettg\CiteProc\Rendering\Date\DateRange;
10
11
use Seboettg\CiteProc\Rendering\Date\DateTime;
12
use Seboettg\Collection\Lists\ListInterface;
13
use Seboettg\Collection\Map\MapInterface;
14
use Seboettg\Collection\Map\Pair;
15
16
class DayRenderer extends DateRangeRenderer
17
{
18
19
    public function parseDateRange(ListInterface $datePartsList, DateTime $from, DateTime $to, string $delimiter): string
20
    {
21
        return $datePartsList->mapNotNull(function (Pair $pair) use ($from, $to, $delimiter) {
22
            $key = $pair->getKey();
23
            $datePart = $pair->getValue();
24
            if (strpos($key, "year") !== false) {
0 ignored issues
show
Bug introduced by
It seems like $key can also be of type boolean; however, parameter $haystack of strpos() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

24
            if (strpos(/** @scrutinizer ignore-type */ $key, "year") !== false) {
Loading history...
25
                return $datePart->render($from, $this->parentDateObject);
26
            }
27
            if (strpos($key, "month") !== false) {
28
                return $datePart->render($from, $this->parentDateObject);
29
            }
30
            if (strpos($key, "day")) {
31
                return $this->renderOneRangePart($datePart, $from, $to, $delimiter);
32
            }
33
            return null;
34
        })->joinToString("");
35
    }
36
}
37