1 | <?php |
||
9 | class BuiltInFunctionsExtension extends AbstractTableBundleExtension |
||
10 | { |
||
11 | /** |
||
12 | * @var TokenStorageInterface |
||
13 | */ |
||
14 | private $tokenStorage; |
||
15 | |||
16 | /** |
||
17 | * @var CurrentDateTimeProvider |
||
18 | */ |
||
19 | private $dateTimeProvider; |
||
20 | |||
21 | /** |
||
22 | * @param TokenStorageInterface $tokenStorage |
||
23 | * @param CurrentDateTimeProvider $dateTimeProvider |
||
24 | */ |
||
25 | public function __construct(TokenStorageInterface $tokenStorage, CurrentDateTimeProvider $dateTimeProvider) |
||
30 | |||
31 | /** |
||
32 | * {@inheritdoc} |
||
33 | */ |
||
34 | public function getName() |
||
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | public function getFunctions() |
||
51 | |||
52 | /** |
||
53 | * Gets the current timestamp, with an offset string |
||
54 | * |
||
55 | * @param string $offset |
||
56 | * |
||
57 | * @return string |
||
58 | * @throws \Exception |
||
59 | */ |
||
60 | public function now($offset = null) |
||
76 | |||
77 | /** |
||
78 | * Gets a date with the hour 00:00:00 |
||
79 | * |
||
80 | * @param string $date |
||
81 | * |
||
82 | * @return string |
||
83 | * @throws \Exception |
||
84 | */ |
||
85 | public function startOfDay($date = null) |
||
97 | |||
98 | /** |
||
99 | * Gets the current users' username |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | public function currentUser() |
||
107 | |||
108 | /** |
||
109 | * Gets a random value between $min and $max |
||
110 | * |
||
111 | * @param int $min |
||
112 | * @param int $max |
||
113 | * |
||
114 | * @return int |
||
115 | */ |
||
116 | public function random($min = 0, $max = 10) |
||
120 | |||
121 | /** |
||
122 | * @param \DateTime $date |
||
123 | * @param string $change |
||
124 | * |
||
125 | * @return \DateTime |
||
126 | * @throws \Exception |
||
127 | */ |
||
128 | private function modifyDate(\DateTime $date, $change) |
||
138 | } |
||
139 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: