Completed
Push — master ( ae2b3a...9c69f7 )
by Sebastian
03:09
created

RestResource::getSupportedMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
namespace Kartenmacherei\RestFramework\RestResource;
3
4
use Kartenmacherei\RestFramework\Request\Method\DeleteRequestMethod;
5
use Kartenmacherei\RestFramework\Request\Method\GetRequestMethod;
6
use Kartenmacherei\RestFramework\Request\Method\PatchRequestMethod;
7
use Kartenmacherei\RestFramework\Request\Method\PostRequestMethod;
8
use Kartenmacherei\RestFramework\Request\Method\PutRequestMethod;
9
use Kartenmacherei\RestFramework\Request\Method\RequestMethod;
10
11
abstract class RestResource
12
{
13
    /**
14
     * @return RequestMethod[]
15
     */
16
    public function getSupportedMethods(): array
17
    {
18
        $methodMap = [
19
            SupportsDeleteRequests::class => new DeleteRequestMethod(),
20
            SupportsGetRequests::class => new GetRequestMethod(),
21
            SupportsPatchRequests::class => new PatchRequestMethod(),
22
            SupportsPostRequests::class => new PostRequestMethod(),
23
            SupportsPutRequests::class => new PutRequestMethod()
24
        ];
25
26
        $implementedInterfaces = class_implements($this);
27
        return array_values(array_intersect_key($methodMap, $implementedInterfaces));
28
    }
29
}
30