PhoneFormatter   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A format() 0 6 1
1
<?php
2
3
namespace App\Utils;
4
5
class PhoneFormatter
6
{
7
    public static function format($phoneNumber)
8
    {
9
        $phoneNumber = preg_replace('/[^0-9]/', '', $phoneNumber);
10
        $len = strlen($phoneNumber);
11
12
        return substr($phoneNumber, 0, $len - 6).' '.substr($phoneNumber, $len - 6, 3).' '.substr($phoneNumber, $len - 3);
13
    }
14
//
15
//    public function created_at()
16
//    {
17
//        return $this->formatDate($this->wrappedObject->created_at);
18
//    }
19
//
20
//    public function updated_at()
21
//    {
22
//        return $this->formatDate($this->wrappedObject->updated_at);
23
//    }
24
//
25
//    public function updated_at_daysdiff()
26
//    {
27
//        $updated_at = $this->wrappedObject->updated_at;
28
//        $now = Carbon::now('Europe/Warsaw');
29
//
30
//        $daysDiff = $updated_at->diffInDays($now);
31
//
32
//        return $daysDiff;
33
//    }
34
//
35
//    protected function formatDate(\DateTime $date)
36
//    {
37
//        $now = Carbon::now('Europe/Warsaw')->endOfDay();
38
//
39
//        $daysDiff = $date->diffInDays($now);
40
//
41
//        if ($daysDiff == 0) {
42
//            return 'Dzisiaj, '.$date->format('H:i');
43
//        }
44
//        elseif ($daysDiff == 1) {
45
//            return 'Wczoraj, '.$date->format('H:i');
46
//        }
47
//        elseif ($daysDiff < 14) {
48
//            return $daysDiff.' dni temu ';
49
//        }
50
//
51
//        return Carbon::createFromFormat('Y-m-d H:i:s', $date)
52
//            ->toFormattedDateString();
53
//    }
54
}
55