Completed
Push — trunk ( 062c60...ebaef8 )
by SuperNova.WS
11:27 queued 05:24
created

AccessLoggedV2::valueDelta()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 4
nop 2
dl 0
loc 12
ccs 0
cts 7
cp 0
crap 12
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by Gorlum 16.06.2017 14:32
4
 */
5
6
namespace Common;
7
8
9
use Exception;
10
11
/**
12
 * Class AccessLoggedV2
13
 *
14
 * Logs property changes. It's necessary for delta and/or partial DB updates
15
 *
16
 * This class differs from AccessLogged that first assignment does goes into $values and does not fills $_startValues
17
 *
18
 * @package Common
19
 */
20
class AccessLoggedV2 extends AccessLogged {
21
  /**
22
   * @param string $name
23
   * @param mixed $value
24
   *
25
   * @throws Exception
26
   */
27
  protected function valueSet($name, $value) {
28
    $this->blockChange($name);
29
30
    $this->_changes[$name] = $value;
31
32
    parent::__set($name, $value);
33
  }
34
35
  /**
36
   * @param string $name
37
   * @param mixed $value
38
   *
39
   * @throws Exception
40
   */
41
  protected function valueDelta($name, $value) {
42
    $this->blockDelta($name);
43
44
    !isset($this->_deltas[$name]) ? $this->_deltas[$name] = 0 : false;
45
46
    $value *= $this->_currentOperation === self::ACCESS_DELTA_DEC ? -1 : +1;
47
48
    $this->_deltas[$name] += $value;
49
50
    parent::__set($name, parent::__get($name) + $value);
51
52
    $this->_currentOperation = self::ACCESS_SET;
53
  }
54
55
}
56