Completed
Push — master ( 2700b4...4ccb05 )
by Torben
04:03 queued 02:37
created

ICalendarDateViewHelper::initializeArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
ccs 0
cts 0
cp 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
namespace DERHANSEN\SfEventMgt\ViewHelpers\Format;
3
4
/*
5
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.txt file that was distributed with this source code.
9
 */
10
11
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
12
13
/**
14
 * ICalendar Description viewhelper
15
 *
16
 * @author Torben Hansen <[email protected]>
17
 */
18
class ICalendarDateViewHelper extends AbstractViewHelper
19
{
20
    /**
21
     * Initialize arguments
22
     */
23
    public function initializeArguments()
24
    {
25
        parent::initializeArguments();
26
        $this->registerArgument('date', 'datetime', 'The DateTime object', false);
27
    }
28
29
    /**
30
     * Formats the given date according to rfc5545
31
     *
32
     * @see http://tools.ietf.org/html/rfc5545#section-3.3.5
33
     * @return string
34
     */
35 6
    public function render()
36
    {
37 6
        $date = $this->arguments['date'];
38 2
        if ($date === null) {
39 2
            $date = $this->renderChildren();
40 6
        }
41 4
        if ($date instanceof \DateTime) {
42
            return gmdate('Ymd\THis\Z', $date->getTimestamp());
43 2
        }
44
45
        return '';
46
    }
47
}
48