Completed
Push — master ( f30a93...2b3d30 )
by Tim
02:07
created

QuarterViewHelper::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
/**
4
 * Link to the quarter.
5
 */
6
declare(strict_types=1);
7
8
namespace HDNET\Calendarize\ViewHelpers\Link;
9
10
use HDNET\Calendarize\Utility\DateTimeUtility;
11
12
/**
13
 * Link to the quarter.
14
 */
15
class QuarterViewHelper extends AbstractLinkViewHelper
16
{
17
    /**
18
     * Init arguments.
19
     */
20
    public function initializeArguments()
21
    {
22
        parent::initializeArguments();
23
        $this->registerArgument('date', \DateTime::class, '', true);
24
        $this->registerArgument('pageUid', 'int', '', false, 0);
25
    }
26
27
    /**
28
     * Render the link to the given quarter.
29
     *
30
     * @return string
31
     */
32
    public function render()
33
    {
34
        if (!\is_object($this->arguments['date'])) {
35
            $this->logger->error('Do not call year viewhelper without date');
36
37
            return $this->renderChildren();
38
        }
39
        $date = $this->arguments['date'];
40
        $additionalParams = [
41
            'tx_calendarize_calendar' => [
42
                'year' => $date->format('Y'),
43
                'quarter' => DateTimeUtility::getQuartar($date),
44
            ],
45
        ];
46
47
        return parent::renderLink($this->getPageUid($this->arguments['pageUid']), $additionalParams);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (renderLink() instead of render()). Are you sure this is correct? If so, you might want to change this to $this->renderLink().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
48
    }
49
}
50