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

ObjectCollection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 71
ccs 0
cts 14
cp 0
rs 10
wmc 5
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetExists() 0 3 1
A offsetGet() 0 3 1
A offsetSet() 0 3 1
A offsetUnset() 0 5 2
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