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

ApiResource::createFromArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
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