Completed
Push — master ( 7256e6...8a8303 )
by Agel_Nash
03:43
created
assets/lib/Helpers/Collection.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 class Collection implements \Countable, \IteratorAggregate, \ArrayAccess{
10 10
     protected $data = array();
11 11
 
12
-    public function __construct(array $data = array()){
12
+    public function __construct(array $data = array()) {
13 13
         $this->data = $data;
14 14
     }
15
-    public function create(array $data = array()){
15
+    public function create(array $data = array()) {
16 16
         return new static($data);
17 17
     }
18 18
     public function getIterator()
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     public function forAll(Closure $p)
39 39
     {
40 40
         foreach ($this->data as $key => $element) {
41
-            if ( ! $p($key, $element)) {
41
+            if (!$p($key, $element)) {
42 42
                 return false;
43 43
             }
44 44
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     {
65 65
         return empty($this->data);
66 66
     }
67
-    public function clear(){
67
+    public function clear() {
68 68
         $this->data = array();
69 69
         return $this;
70 70
     }
@@ -72,20 +72,20 @@  discard block
 block discarded – undo
72 72
         $this->data[] = $value;
73 73
         return $this;
74 74
     }
75
-    public function add($data, $id = null){
76
-        if((is_int($id) || is_string($id)) && $id !== ''){
75
+    public function add($data, $id = null) {
76
+        if ((is_int($id) || is_string($id)) && $id !== '') {
77 77
             $this->data[$id] = $data;
78
-        }else{
78
+        } else {
79 79
             $this->append($data);
80 80
         }
81 81
         return $this;
82 82
     }
83
-    public function count(){
83
+    public function count() {
84 84
         return count($this->data);
85 85
     }
86
-    public function get($id){
86
+    public function get($id) {
87 87
         $out = null;
88
-        if(is_scalar($id) && $id!=='' && $this->containsKey($id)){
88
+        if (is_scalar($id) && $id !== '' && $this->containsKey($id)) {
89 89
             $out = $this->data[$id];
90 90
         }
91 91
         return $out;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     {
109 109
         return key($this->data);
110 110
     }
111
-    public function prev(){
111
+    public function prev() {
112 112
         return prev($this->data);
113 113
     }
114 114
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
     public function remove($key)
126 126
     {
127
-        if ( ! isset($this->data[$key]) && ! array_key_exists($key, $this->data)) {
127
+        if (!isset($this->data[$key]) && !array_key_exists($key, $this->data)) {
128 128
             return null;
129 129
         }
130 130
         $removed = $this->data[$key];
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
     public function offsetSet($offset, $value)
156 156
     {
157
-        if ( ! isset($offset)) {
157
+        if (!isset($offset)) {
158 158
             return $this->add($value);
159 159
         }
160 160
         $this->set($offset, $value);
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         return array_values($this->data);
200 200
     }
201 201
 
202
-    public function toArray(){
202
+    public function toArray() {
203 203
         return $this->data;
204 204
     }
205 205
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
         return $this;
265 265
     }
266 266
 
267
-    public function reindex(){
267
+    public function reindex() {
268 268
         $this->data = array_values($this->data);
269 269
         return $this;
270 270
     }
Please login to merge, or discard this patch.