Completed
Push — master ( 7942ad...1c8947 )
by WEBEWEB
01:50
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
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 31
rs 10

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\Argument;
13
14
use WBW\Library\Core\Utility\Argument\StringUtility;
15
16
/**
17
 * Date utility.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Library\Core\Utility\Argument
21
 * @final
22
 */
23
final class DateUtility implements DateUtilityInterface {
24
25
    /**
26
     * Get the weekday into FR.
27
     *
28
     * @return array Returns the weekday into FR.
29
     */
30
    public static function getWeekdayFR() {
31
        return [
32
            self::EN_WEEKDAY_SUNDAY    => self::FR_WEEKDAY_SUNDAY,
33
            self::EN_WEEKDAY_MONDAY    => self::FR_WEEKDAY_MONDAY,
34
            self::EN_WEEKDAY_TUESDAY   => self::FR_WEEKDAY_TUESDAY,
35
            self::EN_WEEKDAY_WEDNESDAY => self::FR_WEEKDAY_WEDNESDAY,
36
            self::EN_WEEKDAY_THURSDAY  => self::FR_WEEKDAY_THURSDAY,
37
            self::EN_WEEKDAY_FRIDAY    => self::FR_WEEKDAY_FRIDAY,
38
            self::EN_WEEKDAY_SATURDAY  => self::FR_WEEKDAY_SATURDAY,
39
        ];
40
    }
41
42
    /**
43
     * Translate the weekday part.
44
     *
45
     * @param string $date The date.
46
     * @param array $translations The translations: day => translation.
47
     * @return string Returns the weekday part translated.
48
     */
49
    public static function translateWeekday($date, array $translations = []) {
50
        return StringUtility::replace($date, array_keys($translations), array_values($translations));
51
    }
52
53
}
54