Passed
Branch feature/configurable-annotatio... (1a9d97)
by Pieter
02:03
created

ApiResource   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
dl 0
loc 29
rs 10
c 1
b 0
f 1
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFromArray() 0 7 2
1
<?php
2
3
namespace W2w\Lib\Apie\Annotations;
4
5
use Doctrine\Common\Annotations\Annotation\Target;
6
7
/**
8
 * Put this annotation on an API resource to configure how to persist/retrieve an API resource.
9
 *
10
 * @Annotation
11
 * @Target("CLASS")
12
 */
13
class ApiResource
14
{
15
    /**
16
     * @var string
17
     */
18
    public $persistClass;
19
20
    /**
21
     * @var string
22
     */
23
    public $retrieveClass;
24
25
    /**
26
     * @var array
27
     */
28
    public $context = [];
29
30
    /**
31
     * @var string[]
32
     */
33
    public $disabledMethods = [];
34
35
    public static function createFromArray(array $annotations)
36
    {
37
        $result = new self();
38
        foreach ($annotations as $key => $value) {
39
            $result->$key = $value;
40
        }
41
        return $result;
42
    }
43
}
44