Completed
Push — master ( 498091...9beb04 )
by Tim
15s queued 12s
created

WeekViewHelper::getCwYear()   A

Complexity

Conditions 6
Paths 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.2222
c 0
b 0
f 0
cc 6
nc 3
nop 1
1
<?php
2
3
/**
4
 * Link to the week.
5
 */
6
declare(strict_types=1);
7
8
namespace HDNET\Calendarize\ViewHelpers\Link;
9
10
/**
11
 * Link to the week.
12
 */
13
class WeekViewHelper extends AbstractLinkViewHelper
14
{
15
    /**
16
     * Init arguments.
17
     */
18
    public function initializeArguments()
19
    {
20
        parent::initializeArguments();
21
        $this->registerArgument('date', \DateTime::class, '', true);
22
        $this->registerArgument('pageUid', 'int', '', false, 0);
23
        $this->registerArgument('section', 'string', '', false);
24
    }
25
26
    /**
27
     * Render the link to the given day.
28
     *
29
     * @return string
30
     */
31
    public function render()
32
    {
33
        if (!\is_object($this->arguments['date'])) {
34
            $this->logger->error('Do not call week viewhelper without date');
35
36
            return $this->renderChildren();
37
        }
38
        $date = $this->arguments['date'];
39
        $additionalParams = [
40
            'tx_calendarize_calendar' => [
41
                'year' => (int)$date->format('o'),
42
                'week' => (int)$date->format('W'),
43
            ],
44
        ];
45
        $section = isset($this->arguments['section']) ? (string)$this->arguments['section'] : '';
46
47
        return parent::renderLink($this->getPageUid($this->arguments['pageUid']), $additionalParams, false, $section);
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