Passed
Push — master ( 0facf0...5efa68 )
by Yunus Emre
03:38
created

ResourceNames   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildEndpoint() 0 19 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
            {
24 11
                $url = implode('/', array_filter([$url, $endpoint]));
25 11
                continue;
26
            }
27
28 10
            if (is_array($endpoint))
29
            {
30 10
                $url .=  '/'. implode('/', $endpoint);
31 10
                continue;
32
            }
33
        }
34
35 11
        return $url;
36
    }
37
}
38