Completed
Branch master (a6481d)
by Fèvre
02:12
created

UserUtility   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getProfileBackground() 0 11 2
1
<?php
2
namespace Xetaravel\Utility;
3
4
use Carbon\Carbon;
5
6
class UserUtility
7
{
8
    /**
9
     * The prefix of the background images.
10
     *
11
     * @var string
12
     */
13
    protected static $prefix = 'images/profile/bg_profile_';
14
15
    /**
16
     * The extension of the background images.
17
     *
18
     * @var string
19
     */
20
    protected static $extension = '.jpg';
21
22
    /**
23
     * The days references with the images name.
24
     *
25
     * @var array
26
     */
27
    protected static $daysReferences = [
28
        '1' => '1',
29
        '2' => '2',
30
        '3' => '3',
31
        '4' => '4',
32
        '5' => '5',
33
        '6' => '6',
34
        '7' => '7',
35
        '8' => '8',
36
        '9' => '9',
37
        '10' => '10',
38
        '11' => '11',
39
        '12' => '12',
40
        '13' => '13',
41
        '14' => '14',
42
        '15' => '15',
43
        '16' => '1',
44
        '17' => '2',
45
        '18' => '3',
46
        '19' => '4',
47
        '20' => '5',
48
        '21' => '6',
49
        '22' => '7',
50
        '23' => '8',
51
        '24' => '9',
52
        '25' => '10',
53
        '26' => '11',
54
        '27' => '12',
55
        '28' => '13',
56
        '29' => '14',
57
        '30' => '15',
58
        '31' => '1'
59
    ];
60
61
    /**
62
     * Get the profile background by the current day.
63
     *
64
     * @return string
65
     */
66
    public static function getProfileBackground()
67
    {
68
        $now = Carbon::now();
69
        $day = $now->day;
70
71
        if (isset(static::$daysReferences[$day])) {
72
            return static::$prefix . static::$daysReferences[$day] . static::$extension;
73
        }
74
75
        return static::$prefix . '1' . static::$extension;
76
    }
77
}
78