Completed
Push — master ( b70545...93b224 )
by WEBEWEB
04:55
created

DateUtility   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getWeekdayFR() 0 11 1
A translateWeekday() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of the core-library package.
5
 *
6
 * (c) 2018 NdC/WBW
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Library\Core\Utility;
13
14
/**
15
 * Date utility.
16
 *
17
 * @author webeweb <https://github.com/webeweb/>
18
 * @package WBW\Library\Core\Utility
19
 * @final
20
 */
21
final class DateUtility implements DateUtilityInterface {
22
23
    /**
24
     * Get the weekday into FR.
25
     *
26
     * @return array Returns the weekday into FR.
27
     */
28
    public static function getWeekdayFR() {
29
        return [
30
            self::EN_WEEKDAY_SUNDAY    => self::FR_WEEKDAY_SUNDAY,
31
            self::EN_WEEKDAY_MONDAY    => self::FR_WEEKDAY_MONDAY,
32
            self::EN_WEEKDAY_TUESDAY   => self::FR_WEEKDAY_TUESDAY,
33
            self::EN_WEEKDAY_WEDNESDAY => self::FR_WEEKDAY_WEDNESDAY,
34
            self::EN_WEEKDAY_THURSDAY  => self::FR_WEEKDAY_THURSDAY,
35
            self::EN_WEEKDAY_FRIDAY    => self::FR_WEEKDAY_FRIDAY,
36
            self::EN_WEEKDAY_SATURDAY  => self::FR_WEEKDAY_SATURDAY,
37
        ];
38
    }
39
40
    /**
41
     * Translate the weekday part.
42
     *
43
     * @param string $date The date.
44
     * @param array $translations The translations: day => translation.
45
     * @return string Returns the weekday part translated.
46
     */
47
    public static function translateWeekday($date, array $translations = []) {
48
        return StringUtility::replace($date, array_keys($translations), array_values($translations));
49
    }
50
51
}
52