Completed
Pull Request — master (#471)
by
unknown
02:20
created

IfDateLowerViewHelper::initializeArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * Check if a date is lower.
5
 */
6
declare(strict_types=1);
7
8
namespace HDNET\Calendarize\ViewHelpers;
9
10
use HDNET\Calendarize\Utility\DateTimeUtility;
11
12
/**
13
 * Check if a date is lower.
14
 */
15
class IfDateLowerViewHelper extends AbstractViewHelper
16
{
17
    /**
18
     * Initialize arguments.
19
     */
20
    public function initializeArguments(): void
21
    {
22
        parent::initializeArguments();
23
        $this->registerArgument('base', 'mixed', '', true);
24
        $this->registerArgument('check', 'mixed', '', true);
25
    }
26
27
    /**
28
     * Render the view helper.
29
     *
30
     * Note: You have to wrap this view helper in an f:if ViewHelper.
31 1
     * This VH just return a boolean evaluation value
32
     *
33 1
     * @return string
34 1
     */
35 1
    public function render()
36
    {
37
        $base = $this->arguments['base'];
38
        $check = $this->arguments['check'];
39
        $base = DateTimeUtility::normalizeDateTimeSingle($base);
40
        $check = DateTimeUtility::normalizeDateTimeSingle($check);
41
42
        return $base > $check;
43
    }
44
}
45