Completed
Push — master ( cc8041...cf44b9 )
by James
17:47
created
src/Axolotl/Collection.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
 	 * @param array $elements
49 49
 	 * @param array $config
50 50
 	 */
51
-	public function __construct( array $elements = array(), array $config = array() ) {
52
-		$this->parse_config( $this->config = $config );
51
+	public function __construct(array $elements = array(), array $config = array()) {
52
+		$this->parse_config($this->config = $config);
53 53
 
54
-		foreach ( $elements as $element ) {
55
-			$this->add( $element );
54
+		foreach ($elements as $element) {
55
+			$this->add($element);
56 56
 		}
57 57
 	}
58 58
 
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @return $this
67 67
 	 */
68
-	public function add( $element ) {
69
-		if ( $this->model && is_array( $element ) ) {
70
-			$element = new $this->model( $element );
68
+	public function add($element) {
69
+		if ($this->model && is_array($element)) {
70
+			$element = new $this->model($element);
71 71
 		}
72 72
 
73
-		if ( $this->model && ! ( $element instanceof $this->model ) ) {
73
+		if ($this->model && !($element instanceof $this->model)) {
74 74
 			throw new RuntimeException;
75 75
 		}
76 76
 
@@ -86,19 +86,19 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @return $this
88 88
 	 */
89
-	public function remove( $index ) {
90
-		if ( ! is_string( $index ) || ! is_numeric( $index ) || ! isset( $this->elements[ $index ] ) ) {
91
-			foreach ( $this->elements as $key => $element ) {
92
-				if ( $element === $index ) {
89
+	public function remove($index) {
90
+		if (!is_string($index) || !is_numeric($index) || !isset($this->elements[$index])) {
91
+			foreach ($this->elements as $key => $element) {
92
+				if ($element === $index) {
93 93
 					$index = $key;
94 94
 					break;
95 95
 				}
96 96
 			}
97 97
 		}
98 98
 
99
-		if ( isset( $this->elements[ $index ] ) ) {
100
-			unset( $this->elements[ $index ] );
101
-			$this->elements = array_values( $this->elements );
99
+		if (isset($this->elements[$index])) {
100
+			unset($this->elements[$index]);
101
+			$this->elements = array_values($this->elements);
102 102
 		}
103 103
 
104 104
 		return $this;
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @return mixed|null
113 113
 	 */
114
-	public function at( $index ) {
115
-		return isset( $this->elements[ $index ] ) ? $this->elements[ $index ] : null;
114
+	public function at($index) {
115
+		return isset($this->elements[$index]) ? $this->elements[$index] : null;
116 116
 	}
117 117
 
118 118
 	/**
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return Collection
124 124
 	 */
125
-	public function map( callable $callback ) {
126
-		return new Collection( array_map( $callback, $this->elements ), $this->config );
125
+	public function map(callable $callback) {
126
+		return new Collection(array_map($callback, $this->elements), $this->config);
127 127
 	}
128 128
 
129 129
 	/**
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @return Collection
135 135
 	 */
136
-	public function filter( callable $callback ) {
137
-		return new Collection( array_filter( $this->elements, $callback ) );
136
+	public function filter(callable $callback) {
137
+		return new Collection(array_filter($this->elements, $callback));
138 138
 	}
139 139
 
140 140
 	/**
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 	 *
145 145
 	 * @return mixed|null
146 146
 	 */
147
-	public function find( callable $callback ) {
148
-		foreach ( $this->elements as $element ) {
149
-			if ( call_user_func( $callback, $element ) ) {
147
+	public function find(callable $callback) {
148
+		foreach ($this->elements as $element) {
149
+			if (call_user_func($callback, $element)) {
150 150
 				return $element;
151 151
 			}
152 152
 		}
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 	 * @return array
161 161
 	 */
162 162
 	public function serialize() {
163
-		return array_map(function( $element ) {
164
-			if ( $element instanceof Serializes ) {
163
+		return array_map(function($element) {
164
+			if ($element instanceof Serializes) {
165 165
 				return $element->serialize();
166 166
 			}
167 167
 
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
 	 * @return mixed
176 176
 	 */
177 177
 	public function current() {
178
-		return $this->at( $this->position );
178
+		return $this->at($this->position);
179 179
 	}
180 180
 
181 181
 	/**
182 182
 	 * Move forward to next element.
183 183
 	 */
184 184
 	public function next() {
185
-		$this->position ++;
185
+		$this->position++;
186 186
 	}
187 187
 
188 188
 	/**
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @return bool
201 201
 	 */
202 202
 	public function valid() {
203
-		return isset( $this->elements[ $this->position ] );
203
+		return isset($this->elements[$this->position]);
204 204
 	}
205 205
 
206 206
 	/**
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * @return int
217 217
 	 */
218 218
 	public function count() {
219
-		return count( $this->elements );
219
+		return count($this->elements);
220 220
 	}
221 221
 
222 222
 	/**
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @throws LogicException
228 228
 	 */
229
-	protected function parse_config( array $config ) {
230
-		if ( isset( $config['model'] ) ) {
229
+	protected function parse_config(array $config) {
230
+		if (isset($config['model'])) {
231 231
 			$model = $config['model'];
232 232
 
233
-			if ( ! is_subclass_of( $model, 'Intraxia\Jaxion\Axolotl\Model' ) ) {
233
+			if (!is_subclass_of($model, 'Intraxia\Jaxion\Axolotl\Model')) {
234 234
 				throw new LogicException;
235 235
 			}
236 236
 
Please login to merge, or discard this patch.