Passed
Push — main ( 388607...d45280 )
by PRATIK
03:39
created

toDetailBS()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 12
rs 10
cc 4
nc 4
nop 1
1
<?php
2
3
use Carbon\Carbon;
4
use Pratiksh\Nepalidate\Services\NepaliDate;
5
6
if (!function_exists('nepaliDate')) {
7
    function nepaliDate(Carbon $date)
8
    {
9
        $mode = config('nepalidate.mode', 1);
10
        if ($mode == 1) {
11
            return toBS($date);
12
        } elseif ($mode == 2) {
13
            return toFormattedBSDate($date);
14
        } elseif ($mode == 3) {
15
            return toFormattedNepaliDate($date);
16
        } else {
17
            return toBS($date);
18
        }
19
    }
20
}
21
22
if (!function_exists('toBS')) {
23
    function toBS(Carbon $date)
24
    {
25
        return (new NepaliDate())->create($date)->toBS();
26
    }
27
}
28
29
if (!function_exists('toFormattedBSDate')) {
30
    function toFormattedBSDate(Carbon $date)
31
    {
32
        return (new NepaliDate())->create($date)->toFormattedBSDate();
33
    }
34
}
35
36
if (!function_exists('toFormattedNepaliDate')) {
37
    function toFormattedNepaliDate(Carbon $date)
38
    {
39
        return (new NepaliDate())->create($date)->toFormattedNepaliDate();
40
    }
41
}
42
43
if (!function_exists('toDetailBS')) {
44
    function toDetailBS(Carbon $date)
45
    {
46
        $bs_array = (new NepaliDate())->create($date)->toBSArray();
47
        $to_detail_bs = null;
48
        if (!is_null($bs_array)) {
0 ignored issues
show
introduced by
The condition is_null($bs_array) is always false.
Loading history...
49
            if (is_array($bs_array)) {
0 ignored issues
show
introduced by
The condition is_array($bs_array) is always true.
Loading history...
50
                if (count($bs_array) > 0) {
51
                    $to_detail_bs = json_decode(json_encode($bs_array));
52
                }
53
            }
54
        }
55
        return $to_detail_bs;
56
    }
57
}
58