Completed
Push — work-fleets ( 6bf235...9b7cc1 )
by SuperNova.WS
07:25
created

ObjectCollection::offsetSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

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 3
ccs 3
cts 3
cp 1
crap 1
rs 10
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 1
  public function offsetExists($offset) {
35 1
    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 1
  public function offsetGet($offset) {
50 1
    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 1
  public function offsetSet($offset, $value) {
68 1
    $this->attach($value, $offset);
69 1
  }
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 1
  public function offsetUnset($offset) {
83 1
    if($this->offsetExists($offset)) {
84 1
      parent::offsetUnset($this->offsetGet($offset));
85 1
    }
86 1
  }
87
88
}
89