Completed
Pull Request — master (#3)
by James
02:59
created
src/Axolotl/Relationship/BelongsToOne.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 	 * @param string $type
30 30
 	 * @param string $local_key
31 31
 	 */
32
-	public function __construct( Model $model, $class, $type, $local_key ) {
32
+	public function __construct(Model $model, $class, $type, $local_key) {
33 33
 		$this->local_key = $local_key;
34 34
 
35
-		parent::__construct( $model, $class, $type );
35
+		parent::__construct($model, $class, $type);
36 36
 	}
37 37
 
38 38
 	/**
@@ -42,25 +42,25 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @throws LogicException
44 44
 	 */
45
-	public function attach_relation( EntityManager $database ) {
46
-		if ( $this->get_model()->is_filling() ) {
45
+	public function attach_relation(EntityManager $database) {
46
+		if ($this->get_model()->is_filling()) {
47 47
 			return;
48 48
 		}
49 49
 
50
-		$this->get_model()->set_filling( true );
50
+		$this->get_model()->set_filling(true);
51 51
 
52 52
 		$id = $this->make_target_id();
53 53
 
54
-		if ( $id ) {
54
+		if ($id) {
55 55
 			$target = $database->find(
56 56
 				$this->get_class(),
57 57
 				$id
58 58
 			);
59 59
 
60
-			$this->set_target( $target );
60
+			$this->set_target($target);
61 61
 		}
62 62
 
63
-		$this->get_model()->set_filling( false );
63
+		$this->get_model()->set_filling(false);
64 64
 	}
65 65
 
66 66
 	/**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	public function get_sha() {
72 72
 		return sha1(
73 73
 			__CLASS__ .
74
-			get_class( $this->model ) .
74
+			get_class($this->model) .
75 75
 			$this->class .
76 76
 			$this->type .
77 77
 			$this->local_key
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	protected function make_target_id() {
98 98
 		$class = $this->get_class();
99 99
 
100
-		switch ( $this->get_relationship_type() ) {
100
+		switch ($this->get_relationship_type()) {
101 101
 			case 'post_post':
102 102
 				return $this->get_model()
103 103
 					->get_underlying_wp_object()
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 					$class::get_taxonomy()
111 111
 				);
112 112
 
113
-				if ( ! $terms || is_wp_error( $terms ) ) {
113
+				if (!$terms || is_wp_error($terms)) {
114 114
 					return false;
115 115
 				}
116 116
 
Please login to merge, or discard this patch.
src/Axolotl/Relationship/HasMany.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
 	 * @param string $type
29 29
 	 * @param string $foreign_key
30 30
 	 */
31
-	public function __construct( Model $model, $class, $type, $foreign_key ) {
31
+	public function __construct(Model $model, $class, $type, $foreign_key) {
32 32
 		$this->foreign_key = $foreign_key;
33 33
 
34
-		parent::__construct( $model, $class, $type );
34
+		parent::__construct($model, $class, $type);
35 35
 	}
36 36
 
37 37
 	/**
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @throws LogicException
43 43
 	 */
44
-	public function attach_relation( EntityManager $database ) {
45
-		if ( $this->get_model()->is_filling() ) {
44
+	public function attach_relation(EntityManager $database) {
45
+		if ($this->get_model()->is_filling()) {
46 46
 			return;
47 47
 		}
48 48
 
49
-		$this->get_model()->set_filling( true );
49
+		$this->get_model()->set_filling(true);
50 50
 
51
-		switch ( $this->get_type() ) {
51
+		switch ($this->get_type()) {
52 52
 			case 'object':
53 53
 				$target = $database->find_by(
54 54
 					$this->get_class(),
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 				throw new LogicException;
61 61
 		}
62 62
 
63
-		$this->set_target( $target );
63
+		$this->set_target($target);
64 64
 
65
-		$this->get_model()->set_filling( false );
65
+		$this->get_model()->set_filling(false);
66 66
 	}
67 67
 
68 68
 	/**
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	public function get_sha() {
74 74
 		return sha1(
75 75
 			__CLASS__ .
76
-			get_class( $this->model ) .
76
+			get_class($this->model) .
77 77
 			$this->class .
78 78
 			$this->type .
79 79
 			$this->foreign_key
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @throws LogicException
98 98
 	 */
99 99
 	protected function make_target_params() {
100
-		switch ( $this->get_relationship_type() ) {
100
+		switch ($this->get_relationship_type()) {
101 101
 			case 'post_post':
102 102
 				return array(
103 103
 					$this->foreign_key => $this->get_model()->get_primary_id(),
Please login to merge, or discard this patch.
src/Axolotl/Relationship/Root.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * @param string $class
47 47
 	 * @param string $type
48 48
 	 */
49
-	public function __construct( Model $model, $class, $type ) {
49
+	public function __construct(Model $model, $class, $type) {
50 50
 		$this->model = $model;
51 51
 		$this->class = $class;
52 52
 		$this->type  = $type;
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @param Model|Collection $target
86 86
 	 */
87
-	public function set_target( $target ) {
88
-		$this->get_model()->set_related( $this->get_sha(), $target );
87
+	public function set_target($target) {
88
+		$this->get_model()->set_related($this->get_sha(), $target);
89 89
 	}
90 90
 
91 91
 	/**
@@ -96,30 +96,30 @@  discard block
 block discarded – undo
96 96
 	public function get_relationship_type() {
97 97
 		$relationship = '';
98 98
 
99
-		if ( $this->get_model() instanceof UsesWordPressPost ) {
99
+		if ($this->get_model() instanceof UsesWordPressPost) {
100 100
 			$relationship .= 'post';
101
-		} elseif ( $this->get_model() instanceof UsesWordPressTerm ) {
101
+		} elseif ($this->get_model() instanceof UsesWordPressTerm) {
102 102
 			$relationship .= 'term';
103
-		} elseif ( $this->get_model() instanceof UsesCustomTable ) {
103
+		} elseif ($this->get_model() instanceof UsesCustomTable) {
104 104
 			$relationship .= 'table';
105 105
 		}
106 106
 
107 107
 		$relationship .= '_';
108 108
 
109
-		if ( is_subclass_of(
109
+		if (is_subclass_of(
110 110
 			$this->get_class(),
111 111
 			'Intraxia\Jaxion\Contract\Axolotl\UsesWordPressPost'
112
-		) ) {
112
+		)) {
113 113
 			$relationship .= 'post';
114
-		} elseif ( is_subclass_of(
114
+		} elseif (is_subclass_of(
115 115
 			$this->get_class(),
116 116
 			'Intraxia\Jaxion\Contract\Axolotl\UsesWordPressTerm'
117
-		) ) {
117
+		)) {
118 118
 			$relationship .= 'term';
119
-		} elseif ( is_subclass_of(
119
+		} elseif (is_subclass_of(
120 120
 			$this->get_class(),
121 121
 			'Intraxia\Jaxion\Contract\Axolotl\UsesCustomTable'
122
-		) ) {
122
+		)) {
123 123
 			$relationship .= 'table';
124 124
 		}
125 125
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 *
133 133
 	 * @param EntityManager $database
134 134
 	 */
135
-	abstract public function attach_relation( EntityManager $database );
135
+	abstract public function attach_relation(EntityManager $database);
136 136
 
137 137
 	/**
138 138
 	 * Generate the sha for the relation.
Please login to merge, or discard this patch.
src/Axolotl/EntityManager.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @param WP_Query $main
50 50
 	 * @param string   $prefix Post meta prefix.
51 51
 	 */
52
-	public function __construct( WP_Query $main, $prefix ) {
52
+	public function __construct(WP_Query $main, $prefix) {
53 53
 		global $wpdb;
54 54
 
55 55
 		$this->wpdb   = $wpdb;
@@ -67,15 +67,15 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @throws LogicException
69 69
 	 */
70
-	public function find( $class, $id ) {
71
-		$repository = $this->get_repository( $class );
72
-		$model      = $repository->find( $id );
70
+	public function find($class, $id) {
71
+		$repository = $this->get_repository($class);
72
+		$model      = $repository->find($id);
73 73
 
74
-		if ( is_wp_error( $model ) ) {
74
+		if (is_wp_error($model)) {
75 75
 			return $model;
76 76
 		}
77 77
 
78
-		$this->handle_model( $repository, $model );
78
+		$this->handle_model($repository, $model);
79 79
 
80 80
 		return $model;
81 81
 	}
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @throws LogicException
92 92
 	 */
93
-	public function find_by( $class, $params = array() ) {
94
-		$repository = $this->get_repository( $class );
95
-		$collection = $repository->find_by( $params );
93
+	public function find_by($class, $params = array()) {
94
+		$repository = $this->get_repository($class);
95
+		$collection = $repository->find_by($params);
96 96
 
97
-		foreach ( $collection as $model ) {
98
-			$this->handle_model( $repository, $model );
97
+		foreach ($collection as $model) {
98
+			$this->handle_model($repository, $model);
99 99
 		}
100 100
 
101 101
 		return $collection;
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return Model|WP_Error
111 111
 	 */
112
-	public function create( $class, $data = array() ) {
113
-		$repository = $this->get_repository( $class );
114
-		$model      = $repository->create( $data );
112
+	public function create($class, $data = array()) {
113
+		$repository = $this->get_repository($class);
114
+		$model      = $repository->create($data);
115 115
 
116
-		$this->handle_model( $repository, $model );
116
+		$this->handle_model($repository, $model);
117 117
 
118 118
 		return $model;
119 119
 	}
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @return Model|WP_Error
127 127
 	 */
128
-	public function persist( Model $model ) {
129
-		return $this->get_repository( get_class( $model ) )->persist( $model );
128
+	public function persist(Model $model) {
129
+		return $this->get_repository(get_class($model))->persist($model);
130 130
 	}
131 131
 
132 132
 	/**
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return Model|WP_Error
139 139
 	 */
140
-	public function delete( Model $model, $force = false ) {
141
-		return $this->get_repository( get_class( $model ) )->delete( $model, $force );
140
+	public function delete(Model $model, $force = false) {
141
+		return $this->get_repository(get_class($model))->delete($model, $force);
142 142
 	}
143 143
 
144 144
 	/**
@@ -184,30 +184,30 @@  discard block
 block discarded – undo
184 184
 	 *
185 185
 	 * @throws LogicException
186 186
 	 */
187
-	protected function get_repository( $class ) {
187
+	protected function get_repository($class) {
188 188
 		// We can only use Axolotl models.
189
-		if ( ! is_subclass_of( $class, 'Intraxia\Jaxion\Axolotl\Model' ) ) {
189
+		if (!is_subclass_of($class, 'Intraxia\Jaxion\Axolotl\Model')) {
190 190
 			throw new LogicException;
191 191
 		}
192 192
 
193
-		if ( is_subclass_of(
193
+		if (is_subclass_of(
194 194
 			$class,
195 195
 			'Intraxia\Jaxion\Contract\Axolotl\UsesWordPressPost'
196
-		) ) {
197
-			return new WordPressPostRepository( $this, $class );
196
+		)) {
197
+			return new WordPressPostRepository($this, $class);
198 198
 		}
199 199
 
200
-		if ( is_subclass_of(
200
+		if (is_subclass_of(
201 201
 			$class,
202 202
 			'Intraxia\Jaxion\Contract\Axolotl\UsesWordPressTerm'
203
-		) ) {
204
-			return new WordPressTermRepository( $this, $class );
203
+		)) {
204
+			return new WordPressTermRepository($this, $class);
205 205
 		}
206 206
 
207
-		if ( is_subclass_of(
207
+		if (is_subclass_of(
208 208
 			$class,
209 209
 			'Intraxia\Jaxion\Contract\Axolotl\UsesCustomTable'
210
-		) ) {
210
+		)) {
211 211
 			throw new LogicException;
212 212
 		}
213 213
 
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 	 * @param AbstractRepository $repository
223 223
 	 * @param Model              $model
224 224
 	 */
225
-	protected function handle_model( AbstractRepository $repository, Model $model ) {
226
-		$repository->register_model( $model );
225
+	protected function handle_model(AbstractRepository $repository, Model $model) {
226
+		$repository->register_model($model);
227 227
 
228
-		if ( $model instanceof HasEagerRelationships ) {
229
-			$this->fill_related( $model, $model::get_eager_relationships() );
228
+		if ($model instanceof HasEagerRelationships) {
229
+			$this->fill_related($model, $model::get_eager_relationships());
230 230
 		}
231 231
 	}
232 232
 
@@ -240,17 +240,17 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @throws LogicException
242 242
 	 */
243
-	protected function fill_related( Model $model, array $relations = array() ) {
244
-		if ( ! $relations ) {
243
+	protected function fill_related(Model $model, array $relations = array()) {
244
+		if (!$relations) {
245 245
 			$relations = $model->get_related_keys();
246 246
 		}
247 247
 
248
-		foreach ( $relations as $relation ) {
249
-			if ( ! in_array( $relation, $model->get_related_keys() ) ) {
248
+		foreach ($relations as $relation) {
249
+			if (!in_array($relation, $model->get_related_keys())) {
250 250
 				throw new LogicException;
251 251
 			}
252 252
 
253
-			if ( $model->relation_is_filled( $relation ) ) {
253
+			if ($model->relation_is_filled($relation)) {
254 254
 				continue;
255 255
 			}
256 256
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 			 * @var Relationship $relation
261 261
 			 */
262 262
 			$relation = $model->{"related_{$relation}"}();
263
-			$relation->attach_relation( $this );
263
+			$relation->attach_relation($this);
264 264
 		}
265 265
 	}
266 266
 }
Please login to merge, or discard this patch.
src/Axolotl/Model.php 1 patch
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @param array <string, mixed> $attributes
115 115
 	 */
116
-	public function __construct( array $attributes = array() ) {
116
+	public function __construct(array $attributes = array()) {
117 117
 		$this->maybe_boot();
118 118
 		$this->sync_original();
119 119
 
120
-		if ( $this->uses_wp_object() ) {
120
+		if ($this->uses_wp_object()) {
121 121
 			$this->create_wp_object();
122 122
 		}
123 123
 
124
-		$this->refresh( $attributes );
124
+		$this->refresh($attributes);
125 125
 	}
126 126
 
127 127
 	/**
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	 *
133 133
 	 * @param array $attributes
134 134
 	 */
135
-	public function refresh( array $attributes ) {
135
+	public function refresh(array $attributes) {
136 136
 		$this->clear();
137 137
 
138
-		foreach ( $attributes as $name => $value ) {
139
-			$this->set_attribute( $name, $value );
138
+		foreach ($attributes as $name => $value) {
139
+			$this->set_attribute($name, $value);
140 140
 		}
141 141
 	}
142 142
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 	public function get_changed_table_attributes() {
172 172
 		$changed = array();
173 173
 
174
-		foreach ( $this->get_table_attributes() as $attribute ) {
175
-			if ( $this->get_attribute( $attribute ) !==
176
-			     $this->get_original_attribute( $attribute )
174
+		foreach ($this->get_table_attributes() as $attribute) {
175
+			if ($this->get_attribute($attribute) !==
176
+			     $this->get_original_attribute($attribute)
177 177
 			) {
178
-				$changed[ $attribute ] = $this->get_attribute( $attribute );
178
+				$changed[$attribute] = $this->get_attribute($attribute);
179 179
 			}
180 180
 		}
181 181
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 * @return false|WP_Post|WP_Term
192 192
 	 */
193 193
 	public function get_underlying_wp_object() {
194
-		if ( isset( $this->attributes['object'] ) ) {
194
+		if (isset($this->attributes['object'])) {
195 195
 			return $this->attributes['object'];
196 196
 		}
197 197
 
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 	public function get_changed_wp_object_attributes() {
218 218
 		$changed = array();
219 219
 
220
-		foreach ( $this->get_wp_object_keys() as $key ) {
221
-			if ( $this->get_attribute( $key ) !==
222
-			     $this->get_original_attribute( $key )
220
+		foreach ($this->get_wp_object_keys() as $key) {
221
+			if ($this->get_attribute($key) !==
222
+			     $this->get_original_attribute($key)
223 223
 			) {
224
-				$changed[ $key ] = $this->get_attribute( $key );
224
+				$changed[$key] = $this->get_attribute($key);
225 225
 			}
226 226
 		}
227 227
 
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 	 * @param string $name
237 237
 	 * @param mixed  $value
238 238
 	 */
239
-	public function __set( $name, $value ) {
240
-		$this->set_attribute( $name, $value );
239
+	public function __set($name, $value) {
240
+		$this->set_attribute($name, $value);
241 241
 	}
242 242
 
243 243
 	/**
@@ -254,19 +254,19 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @throws GuardedPropertyException
256 256
 	 */
257
-	public function set_attribute( $name, $value ) {
258
-		if ( 'object' === $name ) {
259
-			return $this->override_wp_object( $value );
257
+	public function set_attribute($name, $value) {
258
+		if ('object' === $name) {
259
+			return $this->override_wp_object($value);
260 260
 		}
261 261
 
262
-		if ( ! $this->is_fillable( $name ) ) {
262
+		if (!$this->is_fillable($name)) {
263 263
 			throw new GuardedPropertyException;
264 264
 		}
265 265
 
266
-		if ( $method = $this->has_map_method( $name ) ) {
266
+		if ($method = $this->has_map_method($name)) {
267 267
 			$this->attributes['object']->{$this->{$method}()} = $value;
268 268
 		} else {
269
-			$this->attributes['table'][ $name ] = $value;
269
+			$this->attributes['table'][$name] = $value;
270 270
 		}
271 271
 
272 272
 		return $this;
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
 	 * @return array
279 279
 	 */
280 280
 	public function get_attribute_keys() {
281
-		if ( isset( self::$memo[ get_called_class() ][ __METHOD__ ] ) ) {
282
-			return self::$memo[ get_called_class() ][ __METHOD__ ];
281
+		if (isset(self::$memo[get_called_class()][__METHOD__])) {
282
+			return self::$memo[get_called_class()][__METHOD__];
283 283
 		}
284 284
 
285
-		return self::$memo[ get_called_class() ][ __METHOD__ ]
285
+		return self::$memo[get_called_class()][__METHOD__]
286 286
 			= array_merge(
287 287
 				$this->fillable,
288 288
 				$this->guarded,
@@ -297,22 +297,22 @@  discard block
 block discarded – undo
297 297
 	 * @return array
298 298
 	 */
299 299
 	public function get_table_keys() {
300
-		if ( isset( self::$memo[ get_called_class() ][ __METHOD__ ] ) ) {
301
-			return self::$memo[ get_called_class() ][ __METHOD__ ];
300
+		if (isset(self::$memo[get_called_class()][__METHOD__])) {
301
+			return self::$memo[get_called_class()][__METHOD__];
302 302
 		}
303 303
 
304 304
 		$keys = array();
305 305
 
306
-		foreach ( $this->get_attribute_keys() as $key ) {
307
-			if ( ! $this->has_map_method( $key ) &&
308
-			     ! $this->has_compute_method( $key ) &&
309
-			     ! $this->has_related_method( $key )
306
+		foreach ($this->get_attribute_keys() as $key) {
307
+			if (!$this->has_map_method($key) &&
308
+			     !$this->has_compute_method($key) &&
309
+			     !$this->has_related_method($key)
310 310
 			) {
311 311
 				$keys[] = $key;
312 312
 			}
313 313
 		}
314 314
 
315
-		return self::$memo[ get_called_class() ][ __METHOD__ ] = $keys;
315
+		return self::$memo[get_called_class()][__METHOD__] = $keys;
316 316
 	}
317 317
 
318 318
 	/**
@@ -321,19 +321,19 @@  discard block
 block discarded – undo
321 321
 	 * @return array
322 322
 	 */
323 323
 	public function get_wp_object_keys() {
324
-		if ( isset( self::$memo[ get_called_class() ][ __METHOD__ ] ) ) {
325
-			return self::$memo[ get_called_class() ][ __METHOD__ ];
324
+		if (isset(self::$memo[get_called_class()][__METHOD__])) {
325
+			return self::$memo[get_called_class()][__METHOD__];
326 326
 		}
327 327
 
328 328
 		$keys = array();
329 329
 
330
-		foreach ( $this->get_attribute_keys() as $key ) {
331
-			if ( $this->has_map_method( $key ) ) {
330
+		foreach ($this->get_attribute_keys() as $key) {
331
+			if ($this->has_map_method($key)) {
332 332
 				$keys[] = $key;
333 333
 			}
334 334
 		}
335 335
 
336
-		return self::$memo[ get_called_class() ][ __METHOD__ ] = $keys;
336
+		return self::$memo[get_called_class()][__METHOD__] = $keys;
337 337
 	}
338 338
 
339 339
 	/**
@@ -342,19 +342,19 @@  discard block
 block discarded – undo
342 342
 	 * @return array
343 343
 	 */
344 344
 	public function get_computed_keys() {
345
-		if ( isset( self::$memo[ get_called_class() ][ __METHOD__ ] ) ) {
346
-			return self::$memo[ get_called_class() ][ __METHOD__ ];
345
+		if (isset(self::$memo[get_called_class()][__METHOD__])) {
346
+			return self::$memo[get_called_class()][__METHOD__];
347 347
 		}
348 348
 
349 349
 		$keys = array();
350 350
 
351
-		foreach ( $this->get_attribute_keys() as $key ) {
352
-			if ( $this->has_compute_method( $key ) ) {
351
+		foreach ($this->get_attribute_keys() as $key) {
352
+			if ($this->has_compute_method($key)) {
353 353
 				$keys[] = $key;
354 354
 			}
355 355
 		}
356 356
 
357
-		return self::$memo[ get_called_class() ][ __METHOD__ ] = $keys;
357
+		return self::$memo[get_called_class()][__METHOD__] = $keys;
358 358
 	}
359 359
 
360 360
 	/**
@@ -363,19 +363,19 @@  discard block
 block discarded – undo
363 363
 	 * @return array
364 364
 	 */
365 365
 	public function get_related_keys() {
366
-		if ( isset( self::$memo[ get_called_class() ][ __METHOD__ ] ) ) {
367
-			return self::$memo[ get_called_class() ][ __METHOD__ ];
366
+		if (isset(self::$memo[get_called_class()][__METHOD__])) {
367
+			return self::$memo[get_called_class()][__METHOD__];
368 368
 		}
369 369
 
370 370
 		$keys = array();
371 371
 
372
-		foreach ( $this->get_attribute_keys() as $key ) {
373
-			if ( $this->has_related_method( $key ) ) {
372
+		foreach ($this->get_attribute_keys() as $key) {
373
+			if ($this->has_related_method($key)) {
374 374
 				$keys[] = $key;
375 375
 			}
376 376
 		}
377 377
 
378
-		return self::$memo[ get_called_class() ][ __METHOD__ ] = $keys;
378
+		return self::$memo[get_called_class()][__METHOD__] = $keys;
379 379
 	}
380 380
 
381 381
 	/**
@@ -386,32 +386,32 @@  discard block
 block discarded – undo
386 386
 	public function serialize() {
387 387
 		$attributes = array();
388 388
 
389
-		if ( $this->visible ) {
389
+		if ($this->visible) {
390 390
 			// If visible attributes are set, we'll only reveal those.
391
-			foreach ( $this->visible as $key ) {
392
-				$attributes[ $key ] = $this->get_attribute( $key );
391
+			foreach ($this->visible as $key) {
392
+				$attributes[$key] = $this->get_attribute($key);
393 393
 			}
394
-		} elseif ( $this->hidden ) {
394
+		} elseif ($this->hidden) {
395 395
 			// If hidden attributes are set, we'll grab everything and hide those.
396
-			foreach ( $this->get_attribute_keys() as $key ) {
397
-				if ( ! in_array( $key, $this->hidden ) ) {
398
-					$attributes[ $key ] = $this->get_attribute( $key );
396
+			foreach ($this->get_attribute_keys() as $key) {
397
+				if (!in_array($key, $this->hidden)) {
398
+					$attributes[$key] = $this->get_attribute($key);
399 399
 				}
400 400
 			}
401 401
 		} else {
402 402
 			// If nothing is hidden/visible, we'll grab and reveal everything.
403
-			foreach ( $this->get_attribute_keys() as $key ) {
404
-				$attributes[ $key ] = $this->get_attribute( $key );
403
+			foreach ($this->get_attribute_keys() as $key) {
404
+				$attributes[$key] = $this->get_attribute($key);
405 405
 			}
406 406
 		}
407 407
 
408
-		return array_map( function ( $attribute ) {
409
-			if ( $attribute instanceof Serializes ) {
408
+		return array_map(function($attribute) {
409
+			if ($attribute instanceof Serializes) {
410 410
 				return $attribute->serialize();
411 411
 			}
412 412
 
413 413
 			return $attribute;
414
-		}, $attributes );
414
+		}, $attributes);
415 415
 	}
416 416
 
417 417
 	/**
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	public function sync_original() {
423 423
 		$this->original = $this->attributes;
424 424
 
425
-		if ( $this->attributes['object'] ) {
425
+		if ($this->attributes['object']) {
426 426
 			$this->original['object'] = clone $this->attributes['object'];
427 427
 		}
428 428
 
@@ -438,24 +438,24 @@  discard block
 block discarded – undo
438 438
 	 *
439 439
 	 * @return bool
440 440
 	 */
441
-	private function is_fillable( $name ) {
441
+	private function is_fillable($name) {
442 442
 		// If this model isn't guarded, everything is fillable.
443
-		if ( ! $this->is_guarded ) {
443
+		if (!$this->is_guarded) {
444 444
 			return true;
445 445
 		}
446 446
 
447 447
 		// If it's in the fillable array, then it's fillable.
448
-		if ( in_array( $name, $this->fillable ) ) {
448
+		if (in_array($name, $this->fillable)) {
449 449
 			return true;
450 450
 		}
451 451
 
452 452
 		// If it's explicitly guarded, then it's not fillable.
453
-		if ( in_array( $name, $this->guarded ) ) {
453
+		if (in_array($name, $this->guarded)) {
454 454
 			return false;
455 455
 		}
456 456
 
457 457
 		// If fillable hasn't been defined, then everything else fillable.
458
-		return ! $this->fillable;
458
+		return !$this->fillable;
459 459
 	}
460 460
 
461 461
 	/**
@@ -467,8 +467,8 @@  discard block
 block discarded – undo
467 467
 	 *
468 468
 	 * @return $this
469 469
 	 */
470
-	private function override_wp_object( $value ) {
471
-		$this->attributes['object'] = $this->set_wp_object_constants( $value );
470
+	private function override_wp_object($value) {
471
+		$this->attributes['object'] = $this->set_wp_object_constants($value);
472 472
 
473 473
 		return $this;
474 474
 	}
@@ -482,19 +482,19 @@  discard block
 block discarded – undo
482 482
 	 * @throws LogicException
483 483
 	 */
484 484
 	private function create_wp_object() {
485
-		switch ( true ) {
485
+		switch (true) {
486 486
 			case $this instanceof UsesWordPressPost:
487
-				$object = new WP_Post( (object) array() );
487
+				$object = new WP_Post((object) array());
488 488
 				break;
489 489
 			case $this instanceof UsesWordPressTerm:
490
-				$object = new WP_Term( (object) array() );
490
+				$object = new WP_Term((object) array());
491 491
 				break;
492 492
 			default:
493 493
 				throw new LogicException;
494 494
 				break;
495 495
 		}
496 496
 
497
-		$this->attributes['object'] = $this->set_wp_object_constants( $object );
497
+		$this->attributes['object'] = $this->set_wp_object_constants($object);
498 498
 	}
499 499
 
500 500
 	/**
@@ -508,12 +508,12 @@  discard block
 block discarded – undo
508 508
 	 *
509 509
 	 * @return object
510 510
 	 */
511
-	protected function set_wp_object_constants( $object ) {
512
-		if ( $this instanceof UsesWordPressPost ) {
511
+	protected function set_wp_object_constants($object) {
512
+		if ($this instanceof UsesWordPressPost) {
513 513
 			$object->post_type = $this::get_post_type();
514 514
 		}
515 515
 
516
-		if ( $this instanceof UsesWordPressTerm ) {
516
+		if ($this instanceof UsesWordPressTerm) {
517 517
 			$object->taxonomy = $this::get_taxonomy();
518 518
 		}
519 519
 
@@ -529,8 +529,8 @@  discard block
 block discarded – undo
529 529
 	 *
530 530
 	 * @return mixed
531 531
 	 */
532
-	public function __get( $name ) {
533
-		return $this->get_attribute( $name );
532
+	public function __get($name) {
533
+		return $this->get_attribute($name);
534 534
 	}
535 535
 
536 536
 	/**
@@ -542,19 +542,19 @@  discard block
 block discarded – undo
542 542
 	 *
543 543
 	 * @throws PropertyDoesNotExistException If property isn't found.
544 544
 	 */
545
-	public function get_attribute( $name ) {
546
-		if ( $method = $this->has_map_method( $name ) ) {
545
+	public function get_attribute($name) {
546
+		if ($method = $this->has_map_method($name)) {
547 547
 			$value = $this->attributes['object']->{$this->{$method}()};
548
-		} elseif ( $method = $this->has_compute_method( $name ) ) {
548
+		} elseif ($method = $this->has_compute_method($name)) {
549 549
 			$value = $this->{$method}();
550
-		} else if ( $method = $this->has_related_method( $name ) ) {
551
-			$value = $this->get_related( $this->{$method}()->get_sha() );
550
+		} else if ($method = $this->has_related_method($name)) {
551
+			$value = $this->get_related($this->{$method}()->get_sha());
552 552
 		} else {
553
-			if ( ! isset( $this->attributes['table'][ $name ] ) ) {
553
+			if (!isset($this->attributes['table'][$name])) {
554 554
 				throw new PropertyDoesNotExistException;
555 555
 			}
556 556
 
557
-			$value = $this->attributes['table'][ $name ];
557
+			$value = $this->attributes['table'][$name];
558 558
 		}
559 559
 
560 560
 		return $value;
@@ -569,10 +569,10 @@  discard block
 block discarded – undo
569 569
 	 *
570 570
 	 * @throws PropertyDoesNotExistException If property isn't found.
571 571
 	 */
572
-	public function get_original_attribute( $name ) {
573
-		$original = new static( $this->original );
572
+	public function get_original_attribute($name) {
573
+		$original = new static($this->original);
574 574
 
575
-		return $original->get_attribute( $name );
575
+		return $original->get_attribute($name);
576 576
 	}
577 577
 
578 578
 	/**
@@ -584,11 +584,11 @@  discard block
 block discarded – undo
584 584
 	 * @throws LogicException
585 585
 	 */
586 586
 	public function get_primary_id() {
587
-		if ( $this instanceof UsesWordPressPost ) {
587
+		if ($this instanceof UsesWordPressPost) {
588 588
 			return $this->get_underlying_wp_object()->ID;
589 589
 		}
590 590
 
591
-		if ( $this instanceof UsesWordPressTerm ) {
591
+		if ($this instanceof UsesWordPressTerm) {
592 592
 			return $this->get_underlying_wp_object()->term_id;
593 593
 		}
594 594
 
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 	 * @throws LogicException
606 606
 	 */
607 607
 	public function get_foreign_key() {
608
-		if ( $this instanceof UsesWordPressPost ) {
608
+		if ($this instanceof UsesWordPressPost) {
609 609
 			return 'post_id';
610 610
 		}
611 611
 
@@ -620,8 +620,8 @@  discard block
 block discarded – undo
620 620
 	 *
621 621
 	 * @return Model|Collection
622 622
 	 */
623
-	public function get_related( $sha ) {
624
-		return $this->related[ $sha ];
623
+	public function get_related($sha) {
624
+		return $this->related[$sha];
625 625
 	}
626 626
 
627 627
 	/**
@@ -632,12 +632,12 @@  discard block
 block discarded – undo
632 632
 	 *
633 633
 	 * @throws RuntimeException
634 634
 	 */
635
-	public function set_related( $sha, $target ) {
636
-		if ( ! ( $target instanceof Model ) && ! ( $target instanceof Collection ) ) {
635
+	public function set_related($sha, $target) {
636
+		if (!($target instanceof Model) && !($target instanceof Collection)) {
637 637
 			throw new RuntimeException;
638 638
 		}
639 639
 
640
-		$this->related[ $sha ] = $target;
640
+		$this->related[$sha] = $target;
641 641
 	}
642 642
 
643 643
 	/**
@@ -651,8 +651,8 @@  discard block
 block discarded – undo
651 651
 	 *
652 652
 	 * @return false|string
653 653
 	 */
654
-	protected function has_map_method( $name ) {
655
-		if ( method_exists( $this, $method = "map_{$name}" ) ) {
654
+	protected function has_map_method($name) {
655
+		if (method_exists($this, $method = "map_{$name}")) {
656 656
 			return $method;
657 657
 		}
658 658
 
@@ -669,8 +669,8 @@  discard block
 block discarded – undo
669 669
 	 *
670 670
 	 * @return false|string
671 671
 	 */
672
-	protected function has_compute_method( $name ) {
673
-		if ( method_exists( $this, $method = "compute_{$name}" ) ) {
672
+	protected function has_compute_method($name) {
673
+		if (method_exists($this, $method = "compute_{$name}")) {
674 674
 			return $method;
675 675
 		}
676 676
 
@@ -687,8 +687,8 @@  discard block
 block discarded – undo
687 687
 	 *
688 688
 	 * @return false|string
689 689
 	 */
690
-	protected function has_related_method( $name ) {
691
-		if ( method_exists( $this, $method = "related_{$name}" ) ) {
690
+	protected function has_related_method($name) {
691
+		if (method_exists($this, $method = "related_{$name}")) {
692 692
 			return $method;
693 693
 		}
694 694
 
@@ -706,10 +706,10 @@  discard block
 block discarded – undo
706 706
 	public function clear() {
707 707
 		$keys = $this->get_attribute_keys();
708 708
 
709
-		foreach ( $keys as $key ) {
709
+		foreach ($keys as $key) {
710 710
 			try {
711
-				$this->set_attribute( $key, null );
712
-			} catch ( GuardedPropertyException $e ) {
711
+				$this->set_attribute($key, null);
712
+			} catch (GuardedPropertyException $e) {
713 713
 				// We won't clear out guarded attributes.
714 714
 			}
715 715
 		}
@@ -743,13 +743,13 @@  discard block
 block discarded – undo
743 743
 	 * @return array
744 744
 	 */
745 745
 	protected function get_compute_methods() {
746
-		$methods = get_class_methods( get_called_class() );
747
-		$methods = array_filter( $methods, function ( $method ) {
748
-			return strrpos( $method, 'compute_', - strlen( $method ) ) !== false;
746
+		$methods = get_class_methods(get_called_class());
747
+		$methods = array_filter($methods, function($method) {
748
+			return strrpos($method, 'compute_', - strlen($method)) !== false;
749 749
 		} );
750
-		$methods = array_map( function ( $method ) {
751
-			return substr( $method, strlen( 'compute_' ) );
752
-		}, $methods );
750
+		$methods = array_map(function($method) {
751
+			return substr($method, strlen('compute_'));
752
+		}, $methods);
753 753
 
754 754
 		return $methods;
755 755
 	}
@@ -760,13 +760,13 @@  discard block
 block discarded – undo
760 760
 	 * @return array
761 761
 	 */
762 762
 	protected function get_related_methods() {
763
-		$methods = get_class_methods( get_called_class() );
764
-		$methods = array_filter( $methods, function ( $method ) {
765
-			return strrpos( $method, 'related_', - strlen( $method ) ) !== false;
763
+		$methods = get_class_methods(get_called_class());
764
+		$methods = array_filter($methods, function($method) {
765
+			return strrpos($method, 'related_', - strlen($method)) !== false;
766 766
 		} );
767
-		$methods = array_map( function ( $method ) {
768
-			return substr( $method, strlen( 'related_' ) );
769
-		}, $methods );
767
+		$methods = array_map(function($method) {
768
+			return substr($method, strlen('related_'));
769
+		}, $methods);
770 770
 
771 771
 		return $methods;
772 772
 	}
@@ -778,12 +778,12 @@  discard block
 block discarded – undo
778 778
 	 *
779 779
 	 * @return bool
780 780
 	 */
781
-	public function relation_is_filled( $relation ) {
781
+	public function relation_is_filled($relation) {
782 782
 		$sha = $this
783
-			->{$this->has_related_method( $relation )}()
783
+			->{$this->has_related_method($relation)}()
784 784
 			->get_sha();
785 785
 
786
-		return isset( $this->related[ $sha ] );
786
+		return isset($this->related[$sha]);
787 787
 	}
788 788
 
789 789
 	/**
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 	 *
802 802
 	 * @param bool $is_filling
803 803
 	 */
804
-	public function set_filling( $is_filling ) {
804
+	public function set_filling($is_filling) {
805 805
 		$this->filling = $is_filling;
806 806
 	}
807 807
 
@@ -814,8 +814,8 @@  discard block
 block discarded – undo
814 814
 	 *
815 815
 	 * @return HasMany
816 816
 	 */
817
-	protected function has_many( $class, $type, $foreign_key ) {
818
-		return new HasMany( $this, $class, $type, $foreign_key );
817
+	protected function has_many($class, $type, $foreign_key) {
818
+		return new HasMany($this, $class, $type, $foreign_key);
819 819
 	}
820 820
 
821 821
 	/**
@@ -827,16 +827,16 @@  discard block
 block discarded – undo
827 827
 	 *
828 828
 	 * @return HasMany
829 829
 	 */
830
-	protected function belongs_to_one( $class, $type, $local_key = '' ) {
831
-		return new BelongsToOne( $this, $class, $type, $local_key );
830
+	protected function belongs_to_one($class, $type, $local_key = '') {
831
+		return new BelongsToOne($this, $class, $type, $local_key);
832 832
 	}
833 833
 
834 834
 	/**
835 835
 	 * Sets up the memo array for the creating model.
836 836
 	 */
837 837
 	private function maybe_boot() {
838
-		if ( ! isset( self::$memo[ get_called_class() ] ) ) {
839
-			self::$memo[ get_called_class() ] = array();
838
+		if (!isset(self::$memo[get_called_class()])) {
839
+			self::$memo[get_called_class()] = array();
840 840
 		}
841 841
 	}
842 842
 
Please login to merge, or discard this patch.
src/Axolotl/Collection.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
 	 * @param array $elements
42 42
 	 * @param array $config
43 43
 	 */
44
-	public function __construct( array $elements = array(), array $config = array() ) {
45
-		$this->parse_config( $config );
44
+	public function __construct(array $elements = array(), array $config = array()) {
45
+		$this->parse_config($config);
46 46
 
47
-		foreach ( $elements as $element ) {
48
-			$this->add( $element );
47
+		foreach ($elements as $element) {
48
+			$this->add($element);
49 49
 		}
50 50
 	}
51 51
 
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
 	 *
57 57
 	 * @throws RuntimeException
58 58
 	 */
59
-	public function add( $element ) {
60
-		if ( $this->model && is_array( $element ) ) {
61
-			$element = new $this->model( $element );
59
+	public function add($element) {
60
+		if ($this->model && is_array($element)) {
61
+			$element = new $this->model($element);
62 62
 		}
63 63
 
64
-		if ( $this->model && ! ( $element instanceof $this->model ) ) {
64
+		if ($this->model && !($element instanceof $this->model)) {
65 65
 			throw new RuntimeException;
66 66
 		}
67 67
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return mixed
77 77
 	 */
78
-	public function at( $index ) {
79
-		return $this->elements[ $index ];
78
+	public function at($index) {
79
+		return $this->elements[$index];
80 80
 	}
81 81
 
82 82
 	/**
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
 	 * @return mixed
86 86
 	 */
87 87
 	public function current() {
88
-		return $this->at( $this->position );
88
+		return $this->at($this->position);
89 89
 	}
90 90
 
91 91
 	/**
92 92
 	 * Move forward to next element.
93 93
 	 */
94 94
 	public function next() {
95
-		$this->position ++;
95
+		$this->position++;
96 96
 	}
97 97
 
98 98
 	/**
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @return bool
111 111
 	 */
112 112
 	public function valid() {
113
-		return isset( $this->elements[ $this->position ] );
113
+		return isset($this->elements[$this->position]);
114 114
 	}
115 115
 
116 116
 	/**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @return int
127 127
 	 */
128 128
 	public function count() {
129
-		return count( $this->elements );
129
+		return count($this->elements);
130 130
 	}
131 131
 
132 132
 	/**
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @throws LogicException
138 138
 	 */
139
-	protected function parse_config( array $config ) {
140
-		if ( isset( $config['model'] ) ) {
139
+	protected function parse_config(array $config) {
140
+		if (isset($config['model'])) {
141 141
 			$model = $config['model'];
142 142
 
143
-			if ( ! is_subclass_of( $model, 'Intraxia\Jaxion\Axolotl\Model' ) ) {
143
+			if (!is_subclass_of($model, 'Intraxia\Jaxion\Axolotl\Model')) {
144 144
 				throw new LogicException;
145 145
 			}
146 146
 
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 	 * @return array
155 155
 	 */
156 156
 	public function serialize() {
157
-		return array_map(function( $element ) {
158
-			if ( $element instanceof Serializes ) {
157
+		return array_map(function($element) {
158
+			if ($element instanceof Serializes) {
159 159
 				return $element->serialize();
160 160
 			}
161 161
 
Please login to merge, or discard this patch.
src/Axolotl/ServiceProvider.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@
 block discarded – undo
17 17
 	 *
18 18
 	 * @param Container $container
19 19
 	 */
20
-	public function register( Container $container ) {
20
+	public function register(Container $container) {
21 21
 		$container->define(
22
-			array( 'database' => 'Intraxia\Jaxion\Contract\Axolotl\EntityManager' ),
23
-			function ( $app ) {
24
-				return new EntityManager( new WP_Query, $app->fetch( 'slug' ) );
22
+			array('database' => 'Intraxia\Jaxion\Contract\Axolotl\EntityManager'),
23
+			function($app) {
24
+				return new EntityManager(new WP_Query, $app->fetch('slug'));
25 25
 			}
26 26
 		);
27 27
 	}
Please login to merge, or discard this patch.
src/Utility/Str.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @return bool
21 21
 	 */
22
-	public static function starts_with( $haystack, $needles ) {
23
-		foreach ( (array) $needles as $needle ) {
24
-			if ( '' !== $needle && 0 === strpos( $haystack, $needle ) ) {
22
+	public static function starts_with($haystack, $needles) {
23
+		foreach ((array) $needles as $needle) {
24
+			if ('' !== $needle && 0 === strpos($haystack, $needle)) {
25 25
 				return true;
26 26
 			}
27 27
 		}
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @return bool
39 39
 	 */
40
-	public static function ends_with( $haystack, $needles ) {
41
-		foreach ( (array) $needles as $needle ) {
42
-			if ( substr( $haystack, - strlen( $needle ) ) === (string) $needle ) {
40
+	public static function ends_with($haystack, $needles) {
41
+		foreach ((array) $needles as $needle) {
42
+			if (substr($haystack, - strlen($needle)) === (string) $needle) {
43 43
 				return true;
44 44
 			}
45 45
 		}
Please login to merge, or discard this patch.