Completed
Push — master ( f48f3f...e7b8b9 )
by Yohan
02:34
created

CalendRExtension::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace CalendR\Bridge\Twig;
4
5
use CalendR\Calendar;
6
7
/**
8
 * Extension for using periods and events from Twig
9
 *
10
 * @author Yohan Giarelli <[email protected]>
11
 */
12
class CalendRExtension extends \Twig_Extension
13
{
14
    /**
15
     * @var Calendar
16
     */
17
    protected $factory;
18
19
    /**
20
     * @param Calendar $factory
21
     */
22
    public function __construct(Calendar $factory)
23
    {
24
        $this->factory = $factory;
25
    }
26
27
    /**
28
     * @return array<\Twig_Function>
29
     */
30
    public function getFunctions()
31
    {
32
        return [
33
            new \Twig_SimpleFunction('calendr_year', [$this, 'getYear']),
34
            new \Twig_SimpleFunction('calendr_month', [$this, 'getMonth']),
35
            new \Twig_SimpleFunction('calendr_week', [$this, 'getWeek']),
36
            new \Twig_SimpleFunction('calendr_day', [$this, 'getDay']),
37
            new \Twig_SimpleFunction('calendr_events', [$this, 'getEvents']),
38
        ];
39
    }
40
41
    /**
42
     * @return mixed
43
     */
44
    public function getYear()
45
    {
46
        return call_user_func_array([$this->factory, 'getYear'], func_get_args());
47
    }
48
49
    /**
50
     * @return mixed
51
     */
52
    public function getMonth()
53
    {
54
        return call_user_func_array([$this->factory, 'getMonth'], func_get_args());
55
    }
56
57
    /**
58
     * @return mixed
59
     */
60
    public function getWeek()
61
    {
62
        return call_user_func_array([$this->factory, 'getWeek'], func_get_args());
63
    }
64
65
    /**
66
     * @return mixed
67
     */
68
    public function getDay()
69
    {
70
        return call_user_func_array([$this->factory, 'getDay'], func_get_args());
71
    }
72
73
    /**
74
     * @return mixed
75
     */
76
    public function getEvents()
77
    {
78
        return call_user_func_array([$this->factory, 'getEvents'], func_get_args());
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    public function getName()
85
    {
86
        return self::class;
87
    }
88
}
89