| 1 | <?php |
||
| 8 | class Dates extends DateTime |
||
| 9 | { |
||
| 10 | protected static $humainReadableI18n = [ |
||
| 11 | 'now' => 'Now', |
||
| 12 | 'since' => 'Since', |
||
| 13 | 'yesterday' => 'Testerday', |
||
| 14 | 'the' => 'The', |
||
| 15 | 'at' => 'at' |
||
| 16 | ]; |
||
| 17 | |||
| 18 | protected static $humainReadableFormats = [ |
||
| 19 | 'dateSameYear' => 'm-d', |
||
| 20 | 'dateDifferentYear' => 'Y-m-d', |
||
| 21 | 'time' => 'H:i' |
||
| 22 | ]; |
||
| 23 | |||
| 24 | public static function getHumainReadableI18n() |
||
| 28 | |||
| 29 | public static function setHumainReadableI18nKey($key, $value) |
||
| 33 | |||
| 34 | public static function setHumainReadableI18n($value) |
||
| 38 | |||
| 39 | public static function getHumainReadableFormats() |
||
| 43 | |||
| 44 | public static function setHumainReadableFormatsKey($key, $value) |
||
| 48 | |||
| 49 | public static function setHumainReadableFormats($value) |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Accesseur vers l'attribut $date |
||
| 56 | */ |
||
| 57 | public function getDate() |
||
| 61 | |||
| 62 | public function getYear() |
||
| 66 | |||
| 67 | public function getMonth() |
||
| 71 | |||
| 72 | public function getDay() |
||
| 76 | |||
| 77 | public function getHour() |
||
| 81 | |||
| 82 | public function getMinute() |
||
| 86 | |||
| 87 | public function getSecond() |
||
| 91 | |||
| 92 | public function getZone() |
||
| 96 | |||
| 97 | public function modify($modify) |
||
| 98 | { |
||
| 99 | $dateDepart = clone $this; |
||
| 100 | parent::modify($modify); |
||
| 101 | |||
| 102 | if ($dateDepart == $this) { |
||
| 103 | return $this; |
||
| 104 | } |
||
| 105 | |||
| 106 | $this->modifyOthersKeywords($modify); |
||
| 107 | |||
| 108 | return $this; |
||
| 109 | } |
||
| 110 | |||
| 111 | protected function getModifyOthersKeywors() |
||
| 138 | |||
| 139 | protected function modifyOthersKeywords($modify) |
||
| 162 | |||
| 163 | /** |
||
| 164 | * Renvoi au format pour SQL (postgresql) via un array |
||
| 165 | * |
||
| 166 | * @param bool $returnArray (default: false) Indique si on veux retourner |
||
| 167 | * un string ayant tout, ou un array ayant la date et l'heure séparé |
||
| 168 | * |
||
| 169 | * @return string|array Le format pour SQL |
||
| 170 | * Si string : aaaa-mm-jj hh:mm:ss |
||
| 171 | * Si array : [0]=>partie date (aaaa-mm-jj), [1]=>partie heure (hh:mm:ss) |
||
| 172 | */ |
||
| 173 | public function getSql($returnArray = false) |
||
| 184 | |||
| 185 | /** |
||
| 186 | * Liste tous les timezone qui existe |
||
| 187 | * |
||
| 188 | * @return array La liste des timezone possible |
||
| 189 | */ |
||
| 190 | public function lstTimeZone() |
||
| 191 | { |
||
| 192 | return parent::getTimezone()->listIdentifiers(); |
||
|
1 ignored issue
–
show
|
|||
| 193 | } |
||
| 194 | |||
| 195 | /** |
||
| 196 | * Liste les continents possible pour les timezones |
||
| 197 | * |
||
| 198 | * @return string[] La liste des continents |
||
| 199 | */ |
||
| 200 | public function lstTimeZoneContinent() |
||
| 201 | { |
||
| 202 | return [ |
||
| 203 | 'africa', |
||
| 204 | 'america', |
||
| 205 | 'antartica', |
||
| 206 | 'arctic', |
||
| 207 | 'asia', |
||
| 208 | 'atlantic', |
||
| 209 | 'australia', |
||
| 210 | 'europe', |
||
| 211 | 'indian', |
||
| 212 | 'pacific' |
||
| 213 | ]; |
||
| 214 | } |
||
| 215 | |||
| 216 | /** |
||
| 217 | * Liste des pays possible pour un continent donné |
||
| 218 | * |
||
| 219 | * @param string $continent Le continent dans lequel on veux la liste des pays |
||
| 220 | * |
||
| 221 | * @return array La liste des pays pour le continent donné |
||
| 222 | */ |
||
| 223 | public function lstTimeZonePays($continent) |
||
| 224 | { |
||
| 225 | $lst_all = $this->lstTimeZone(); |
||
| 226 | $return = []; |
||
| 227 | |||
| 228 | $pos = false; |
||
| 229 | foreach ($lst_all as $val) { |
||
| 230 | $pos = strpos($val, $continent); |
||
| 231 | |||
| 232 | if ($pos !== false) { |
||
| 233 | $return[] = $val; |
||
| 234 | } |
||
| 235 | } |
||
| 236 | |||
| 237 | return $return; |
||
| 238 | } |
||
| 239 | |||
| 240 | public function humainReadable($returnDateAndTime = true, $toLower = false) |
||
| 304 | } |
||
| 305 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()method in theSoncalls the wrong method in the parent class.