ApiResource::createFromArray()   A
last analyzed

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
    /**
36
     * @param mixed[] $annotations
37
     * @return ApiResource
38
     */
39
    public static function createFromArray(array $annotations): self
40
    {
41
        $result = new self();
42
        foreach ($annotations as $key => $value) {
43
            $result->$key = $value;
44
        }
45
        return $result;
46
    }
47
}
48