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

Method::create()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 10.5

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 6
cts 12
cp 0.5
rs 8.8571
c 0
b 0
f 0
cc 6
eloc 13
nc 6
nop 1
crap 10.5
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