EndpointAware   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A isEndpoint() 0 7 4
1
<?php
2
3
namespace Cerbero\LazyJson\Concerns;
4
5
/**
6
 * The endpoint aware trait.
7
 *
8
 */
9
trait EndpointAware
10
{
11
    /**
12
     * Determine whether the given item may point to an endpoint
13
     *
14
     * @param mixed $item
15
     * @return bool
16
     */
17 10
    public function isEndpoint($item): bool
18
    {
19 10
        if (!is_string($item) || ($url = parse_url($item)) === false) {
20 7
            return false;
21
        }
22
23 4
        return in_array($url['scheme'] ?? null, ['http', 'https']) && isset($url['host']);
24
    }
25
}
26