Completed
Push — work-fleets ( d6880d...ad253d )
by SuperNova.WS
07:04
created

ObjectCollection::offsetUnset()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 5
ccs 0
cts 5
cp 0
crap 6
rs 9.4285
1
<?php
2
3
/**
4
 * Created by Gorlum 21.08.2016 3:00
5
 */
6
7
namespace Common;
8
9
10
/**
11
 * Class ObjectCollection
12
 *
13
 * Remaps ArrayAccess interface to work with indexed objects only
14
 *
15
 * @package Common
16
 */
17
18
class ObjectCollection extends IndexedObjectStorage {
19
20
  /**
21
   * Whether a offset exists
22
   * @link http://php.net/manual/en/arrayaccess.offsetexists.php
23
   *
24
   * @param mixed $offset <p>
25
   * An offset to check for.
26
   * </p>
27
   *
28
   * @return boolean true on success or false on failure.
29
   * </p>
30
   * <p>
31
   * The return value will be casted to boolean if non-boolean was returned.
32
   * @since 5.0.0
33
   */
34
  public function offsetExists($offset) {
35
    return $this->indexIsSet($offset);
36
  }
37
38
  /**
39
   * Offset to retrieve
40
   * @link http://php.net/manual/en/arrayaccess.offsetget.php
41
   *
42
   * @param mixed $offset <p>
43
   * The offset to retrieve.
44
   * </p>
45
   *
46
   * @return mixed Can return all value types.
47
   * @since 5.0.0
48
   */
49
  public function offsetGet($offset) {
50
    return $this->indexGetObject($offset);
51
  }
52
53
  /**
54
   * Offset to set
55
   * @link http://php.net/manual/en/arrayaccess.offsetset.php
56
   *
57
   * @param mixed $offset <p>
58
   * The offset to assign the value to.
59
   * </p>
60
   * @param mixed $value <p>
61
   * The value to set.
62
   * </p>
63
   *
64
   * @return void
65
   * @since 5.0.0
66
   */
67
  public function offsetSet($offset, $value) {
68
    $this->attach($value, $offset);
69
  }
70
71
  /**
72
   * Offset to unset
73
   * @link http://php.net/manual/en/arrayaccess.offsetunset.php
74
   *
75
   * @param mixed $offset <p>
76
   * The offset to unset.
77
   * </p>
78
   *
79
   * @return void
80
   * @since 5.0.0
81
   */
82
  public function offsetUnset($offset) {
83
    if($this->offsetExists($offset)) {
84
      parent::offsetUnset($this->offsetGet($offset));
85
    }
86
  }
87
88
}
89