ModelProxy::__construct()   B
last analyzed

Complexity

Conditions 6
Paths 24

Size

Total Lines 27
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 18.1218

Importance

Changes 4
Bugs 1 Features 0
Metric Value
c 4
b 1
f 0
dl 0
loc 27
ccs 7
cts 23
cp 0.3043
rs 8.439
cc 6
eloc 18
nc 24
nop 1
crap 18.1218
1
<?php
2
3
namespace Tpg\ExtjsBundle\Annotation;
4
5
/**
6
 * Description of proxy for model
7
 *
8
 * @Annotation
9
 * @Target("CLASS")
10
 */
11
final class ModelProxy
12
{
13
    /** @var string Name of proxy */
14
    public $name = 'memory';
15
    /** @var array Options */
16
    public $option = array();
17
    /** @var array Reader params */
18
    public $reader = array();
19
    /** @var array Writer params */
20
    public $writer = array();
21
22
    /**
23
     * Constructor.
24
     *
25
     * @param array $values Values
26
     */
27 6
    public function __construct($values)
28
    {
29 6
        if (isset($values['value'])) {
30
            $this->name = "rest";
31
            $this->option = array(
32
                "url" => $values['value'],
33
                "format" => "json",
34
            );
35
            $this->writer = array(
36
                "type" => "json",
37
                "writeRecordId" => false,
38
            );
39
        } else {
40 6
            if (isset($values['name'])) {
41
                $this->name = $values['name'];
42
            }
43
        }
44 6
        if (isset($values['option'])) {
45
            $this->option = array_merge($this->option, $values['option']);
46
        }
47 6
        if (isset($values['writer'])) {
48
            $this->writer = array_merge($this->writer, $values['writer']);
49
        }
50 6
        if (isset($values['reader'])) {
51
            $this->reader = $values['reader'];
52
        }
53
    }
54
}