Add   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 35
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPrefix() 0 4 1
A updateProperty() 0 10 2
1
<?php
2
3
namespace Saxulum\Accessor\Accessors;
4
5
use Saxulum\Accessor\CallbackBag;
6
use Saxulum\Accessor\Prop;
7
8
class Add extends AbstractCollection
9
{
10
    const PREFIX = 'add';
11
12
    /**
13
     * @var array
14
     */
15
    protected static $remoteToPrefixMapping = array(
16
        Prop::REMOTE_ONE => Set::PREFIX,
17
        Prop::REMOTE_MANY => Add::PREFIX,
18
    );
19
20
    /**
21
     * @return string
22
     */
23
    public function getPrefix()
24
    {
25
        return self::PREFIX;
26
    }
27
28
    /**
29
     * @param  CallbackBag $callbackBag
30
     * @throws \Exception
31
     */
32
    protected function updateProperty(CallbackBag $callbackBag)
33
    {
34
        $collection = $this->getCollection($callbackBag);
35
        $value = $callbackBag->getArgument(0);
36
        if (null !== $callbackBag->getMappedType()) {
37
            $this->handleMappedBy($callbackBag);
38
        }
39
40
        $collection->add($value);
41
    }
42
}
43