Completed
Push — work-fleets ( dea33d...b19a67 )
by SuperNova.WS
05:56
created

PropertyHiderInObject::setProperty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
rs 9.4285
1
<?php
2
3
class PropertyHiderInObject extends PropertyHider {
4
  private function getPhysicalPropertyName($name) {
5
    return '_' . $name;
6
  }
7
8
  /**
9
   * Method checks if action is available for named property
10
   *
11
   * @param string $name
12
   * @param string $action
13
   *
14
   * @return bool
15
   */
16
  protected function isPropertyActionAvailable($name, $action = '') {
17
    // By default all action available for existing properties
18
    return property_exists($this, $this->getPhysicalPropertyName($name));
19
  }
20
21
  /**
22
   * Internal method that make real changes to property value
23
   * May be override in child class
24
   *
25
   * @param string $name
26
   * @param mixed  $value
27
   *
28
   * @return mixed
29
   */
30
  protected function setProperty($name, $value) {
31
    // TODO: Change property only if value differs ????
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
32
//      if($this->{$this->getPhysicalPropertyName($name)} !== $value) {
33
//      }
34
    return $this->{$this->getPhysicalPropertyName($name)} = $value;
35
  }
36
37
  /**
38
   * Internal method that make really reads property value
39
   * May be override in child class
40
   *
41
   * @param string $name
42
   * @param mixed  $value - ignored. Used for compatibility
43
   *
44
   * @return mixed
45
   */
46
  protected function getProperty($name, $value = null) {
47
    return $this->{$this->getPhysicalPropertyName($name)};
48
  }
49
50
  /**
51
   * Magic method that checks if named property is set
52
   * May be override in child class
53
   *
54
   * @param $name
55
   *
56
   * @return bool
57
   */
58
  public function __isset($name) {
59
    return isset($this->{$this->getPhysicalPropertyName($name)});
60
  }
61
62
}
63