Failed Conditions
Push — experimental/sf ( 267a6e...28d741 )
by Ryo
1408:20 queued 1400:20
created

IntlExtension::date_day()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 8
rs 10
c 0
b 0
f 0
ccs 3
cts 4
cp 0.75
crap 2.0625
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Twig\Extension;
15
16
use Twig\Environment;
17
use Twig\Extension\AbstractExtension;
18
use Twig\TwigFilter;
19
20
class IntlExtension extends AbstractExtension
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25 240
    public function getFilters()
26
    {
27
        return [
28 240
            new TwigFilter('date_day', [$this, 'date_day'], ['needs_environment' => true]),
29 240
            new TwigFilter('date_min', [$this, 'date_min'], ['needs_environment' => true]),
30 240
            new TwigFilter('date_sec', [$this, 'date_sec'], ['needs_environment' => true]),
31
        ];
32
    }
33
34
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$date" missing
Loading history...
35
     * localizeddate('medium', 'none')のショートカット.
36
     *
37
     * 2015/08/28のように、日までのフォーマットで表示します(localeがjaの場合).
38
     * null,空文字に対して利用した場合は、空文字を返却します.
39
     *
40
     * @param Environment $env
41
     * @param $date
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
42
     *
43
     * @return bool|string
44
     */
45 1
    public function date_day(Environment $env, $date)
0 ignored issues
show
Coding Style introduced by
Method name "IntlExtension::date_day" is not in camel caps format
Loading history...
46
    {
47 1
        if (!$date) {
48
            return '';
49
        }
50
51 1
        return \twig_localized_date_filter($env, $date, 'medium', 'none');
52
    }
53
54
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$date" missing
Loading history...
55
     * localizeddate('medium', 'short')のショートカット.
56
     *
57
     * 2015/08/28 16:13のように、分までのフォーマットで表示します(localeがjaの場合).
58
     * null,空文字に対して利用した場合は、空文字を返却します.
59
     *
60
     * @param Environment $env
61
     * @param $date
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
62
     *
63
     * @return bool|string
64
     */
65 142
    public function date_min(Environment $env, $date)
0 ignored issues
show
Coding Style introduced by
Method name "IntlExtension::date_min" is not in camel caps format
Loading history...
66
    {
67 142
        if (!$date) {
68 141
            return '';
69
        }
70
71 9
        return \twig_localized_date_filter($env, $date, 'medium', 'short');
72
    }
73
74
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$date" missing
Loading history...
75
     * localizeddate('medium', 'medium')のショートカット.
76
     *
77
     * 2015/08/28 16:13:05(localeがjaの場合).
78
     * null,空文字に対して利用した場合は、空文字を返却します.
79
     *
80
     * @param Environment $env
81
     * @param $date
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
82
     *
83
     * @return bool|string
84
     */
85 5
    public function date_sec(Environment $env, $date)
0 ignored issues
show
Coding Style introduced by
Method name "IntlExtension::date_sec" is not in camel caps format
Loading history...
86
    {
87 5
        if (!$date) {
88 2
            return '';
89
        }
90
91 4
        return \twig_localized_date_filter($env, $date, 'medium', 'medium');
92
    }
93
}
94