DetectsEndpoints   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 13
ccs 4
cts 4
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A isEndpoint() 0 5 3
1
<?php
2
3
namespace Cerbero\JsonParser\Concerns;
4
5
use function is_array;
6
use function in_array;
7
8
/**
9
 * The trait to detect endpoints.
10
 *
11
 */
12
trait DetectsEndpoints
13
{
14
    /**
15
     * Determine whether the given value points to an endpoint
16
     *
17
     * @param string $value
18
     * @return bool
19
     */
20 348
    protected function isEndpoint(string $value): bool
21
    {
22 348
        return is_array($url = parse_url($value))
23 348
            && in_array($url['scheme'] ?? null, ['http', 'https'])
24 348
            && isset($url['host']);
25
    }
26
}
27