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

RestResource   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 19
c 0
b 0
f 0
wmc 1
lcom 0
cbo 5
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSupportedMethods() 0 13 1
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