DetectsEndpoints::isEndpoint()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 3
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 3
rs 10
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