helpers.php ➔ phone()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 0
loc 10
ccs 4
cts 4
cp 1
crap 2
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
use Propaganistas\LaravelPhone\PhoneNumber;
4
5
if (! function_exists('phone')) {
6
    /**
7
     * Get a PhoneNumber instance or a formatted string.
8
     *
9
     * @param string       $number
10
     * @param string|array $country
11
     * @param string       $format
12
     * @return string|Propaganistas\LaravelPhone\PhoneNumber
13
     */
14
    function phone($number, $country = [], $format = null)
15
    {
16 3
        $phone = PhoneNumber::make($number, $country);
17
18 3
        if (! is_null($format)) {
19 3
            return $phone->format($format);
20
        }
21
22 3
        return $phone;
23
    }
24
}
25