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

Method::getName()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 1
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