ResourceNames   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildEndpoint() 0 17 4
1
<?php
2
3
namespace TarfinLabs\Parasut\Enums;
4
5
class ResourceNames
6
{
7
    public const CONTACT = 'contacts';
8
    public const PRODUCT = 'products';
9
10
    /**
11
     * Build the endpoint string from array or string parts.
12
     *
13
     * @param  mixed  ...$endpoints
14
     *
15
     * @return string
16
     */
17 11
    public static function buildEndpoint(...$endpoints): string
18
    {
19 11
        $url = '';
20
21 11
        foreach ($endpoints as $endpoint) {
22 11
            if (is_string($endpoint)) {
23 11
                $url = implode('/', array_filter([$url, $endpoint]));
24 11
                continue;
25
            }
26
27 10
            if (is_array($endpoint)) {
28 10
                $url .= '/'.implode('/', $endpoint);
29 10
                continue;
30
            }
31
        }
32
33 11
        return $url;
34
    }
35
}
36