Completed
Push — standalone ( 787e4c...e35bae )
by Philip
07:04
created

Method   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 5
dl 0
loc 32
ccs 6
cts 12
cp 0.5
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
getName() 0 1 ?
B create() 0 16 6
1
<?php
2
3
namespace Dontdrinkandroot\RestBundle\Metadata\Annotation;
4
5
abstract class Method
6
{
7
    const LIST = 'LIST';
8
    const POST = 'POST';
9
    const GET = 'GET';
10
    const PUT = 'PUT';
11
    const DELETE = 'DELETE';
12
13
    /**
14
     * @var \Dontdrinkandroot\RestBundle\Metadata\Annotation\Right
15
     */
16
    public $right;
17
18
    abstract public function getName(): string;
19
20 18
    public static function create(string $name): Method
21
    {
22
        switch ($name) {
23 18
            case 'LIST':
24 16
                return new MethodList();
25 4
            case 'POST':
26
                return new MethodPost();
27 4
            case 'GET':
28 4
                return new MethodGet();
29
            case 'PUT':
30
                return new MethodPut();
31
            case 'DELETE':
32
                return new MethodDelete();
33
        }
34
        throw new \RuntimeException(sprintf('Unknown Method %s', $name));
35
    }
36
}
37