Completed
Pull Request — master (#3)
by James
03:03
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/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.
src/Axolotl/Model.php 1 patch
Spacing   +128 added lines, -128 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
 	/**
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @return $this
136 136
 	 */
137
-	public function refresh( array $attributes ) {
137
+	public function refresh(array $attributes) {
138 138
 		$this->clear();
139 139
 
140
-		return $this->merge( $attributes );
140
+		return $this->merge($attributes);
141 141
 	}
142 142
 
143 143
 	/**
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @return $this
151 151
 	 */
152
-	public function merge( array $attributes ) {
153
-		foreach ( $attributes as $name => $value ) {
154
-			$this->set_attribute( $name, $value );
152
+	public function merge(array $attributes) {
153
+		foreach ($attributes as $name => $value) {
154
+			$this->set_attribute($name, $value);
155 155
 		}
156 156
 
157 157
 		return $this;
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 	public function get_changed_table_attributes() {
189 189
 		$changed = array();
190 190
 
191
-		foreach ( $this->get_table_attributes() as $attribute ) {
192
-			if ( $this->get_attribute( $attribute ) !==
193
-			     $this->get_original_attribute( $attribute )
191
+		foreach ($this->get_table_attributes() as $attribute) {
192
+			if ($this->get_attribute($attribute) !==
193
+			     $this->get_original_attribute($attribute)
194 194
 			) {
195
-				$changed[ $attribute ] = $this->get_attribute( $attribute );
195
+				$changed[$attribute] = $this->get_attribute($attribute);
196 196
 			}
197 197
 		}
198 198
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @return false|WP_Post|WP_Term
209 209
 	 */
210 210
 	public function get_underlying_wp_object() {
211
-		if ( isset( $this->attributes['object'] ) ) {
211
+		if (isset($this->attributes['object'])) {
212 212
 			return $this->attributes['object'];
213 213
 		}
214 214
 
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
 	public function get_changed_wp_object_attributes() {
235 235
 		$changed = array();
236 236
 
237
-		foreach ( $this->get_wp_object_keys() as $key ) {
238
-			if ( $this->get_attribute( $key ) !==
239
-			     $this->get_original_attribute( $key )
237
+		foreach ($this->get_wp_object_keys() as $key) {
238
+			if ($this->get_attribute($key) !==
239
+			     $this->get_original_attribute($key)
240 240
 			) {
241
-				$changed[ $key ] = $this->get_attribute( $key );
241
+				$changed[$key] = $this->get_attribute($key);
242 242
 			}
243 243
 		}
244 244
 
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 	 * @param string $name
254 254
 	 * @param mixed  $value
255 255
 	 */
256
-	public function __set( $name, $value ) {
257
-		$this->set_attribute( $name, $value );
256
+	public function __set($name, $value) {
257
+		$this->set_attribute($name, $value);
258 258
 	}
259 259
 
260 260
 	/**
@@ -271,19 +271,19 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * @throws GuardedPropertyException
273 273
 	 */
274
-	public function set_attribute( $name, $value ) {
275
-		if ( 'object' === $name ) {
276
-			return $this->override_wp_object( $value );
274
+	public function set_attribute($name, $value) {
275
+		if ('object' === $name) {
276
+			return $this->override_wp_object($value);
277 277
 		}
278 278
 
279
-		if ( ! $this->is_fillable( $name ) ) {
279
+		if (!$this->is_fillable($name)) {
280 280
 			throw new GuardedPropertyException;
281 281
 		}
282 282
 
283
-		if ( $method = $this->has_map_method( $name ) ) {
283
+		if ($method = $this->has_map_method($name)) {
284 284
 			$this->attributes['object']->{$this->{$method}()} = $value;
285 285
 		} else {
286
-			$this->attributes['table'][ $name ] = $value;
286
+			$this->attributes['table'][$name] = $value;
287 287
 		}
288 288
 
289 289
 		return $this;
@@ -295,11 +295,11 @@  discard block
 block discarded – undo
295 295
 	 * @return array
296 296
 	 */
297 297
 	public function get_attribute_keys() {
298
-		if ( isset( self::$memo[ get_called_class() ][ __METHOD__ ] ) ) {
299
-			return self::$memo[ get_called_class() ][ __METHOD__ ];
298
+		if (isset(self::$memo[get_called_class()][__METHOD__])) {
299
+			return self::$memo[get_called_class()][__METHOD__];
300 300
 		}
301 301
 
302
-		return self::$memo[ get_called_class() ][ __METHOD__ ]
302
+		return self::$memo[get_called_class()][__METHOD__]
303 303
 			= array_merge(
304 304
 				$this->fillable,
305 305
 				$this->guarded,
@@ -314,22 +314,22 @@  discard block
 block discarded – undo
314 314
 	 * @return array
315 315
 	 */
316 316
 	public function get_table_keys() {
317
-		if ( isset( self::$memo[ get_called_class() ][ __METHOD__ ] ) ) {
318
-			return self::$memo[ get_called_class() ][ __METHOD__ ];
317
+		if (isset(self::$memo[get_called_class()][__METHOD__])) {
318
+			return self::$memo[get_called_class()][__METHOD__];
319 319
 		}
320 320
 
321 321
 		$keys = array();
322 322
 
323
-		foreach ( $this->get_attribute_keys() as $key ) {
324
-			if ( ! $this->has_map_method( $key ) &&
325
-			     ! $this->has_compute_method( $key ) &&
326
-			     ! $this->has_related_method( $key )
323
+		foreach ($this->get_attribute_keys() as $key) {
324
+			if (!$this->has_map_method($key) &&
325
+			     !$this->has_compute_method($key) &&
326
+			     !$this->has_related_method($key)
327 327
 			) {
328 328
 				$keys[] = $key;
329 329
 			}
330 330
 		}
331 331
 
332
-		return self::$memo[ get_called_class() ][ __METHOD__ ] = $keys;
332
+		return self::$memo[get_called_class()][__METHOD__] = $keys;
333 333
 	}
334 334
 
335 335
 	/**
@@ -338,19 +338,19 @@  discard block
 block discarded – undo
338 338
 	 * @return array
339 339
 	 */
340 340
 	public function get_wp_object_keys() {
341
-		if ( isset( self::$memo[ get_called_class() ][ __METHOD__ ] ) ) {
342
-			return self::$memo[ get_called_class() ][ __METHOD__ ];
341
+		if (isset(self::$memo[get_called_class()][__METHOD__])) {
342
+			return self::$memo[get_called_class()][__METHOD__];
343 343
 		}
344 344
 
345 345
 		$keys = array();
346 346
 
347
-		foreach ( $this->get_attribute_keys() as $key ) {
348
-			if ( $this->has_map_method( $key ) ) {
347
+		foreach ($this->get_attribute_keys() as $key) {
348
+			if ($this->has_map_method($key)) {
349 349
 				$keys[] = $key;
350 350
 			}
351 351
 		}
352 352
 
353
-		return self::$memo[ get_called_class() ][ __METHOD__ ] = $keys;
353
+		return self::$memo[get_called_class()][__METHOD__] = $keys;
354 354
 	}
355 355
 
356 356
 	/**
@@ -359,19 +359,19 @@  discard block
 block discarded – undo
359 359
 	 * @return array
360 360
 	 */
361 361
 	public function get_computed_keys() {
362
-		if ( isset( self::$memo[ get_called_class() ][ __METHOD__ ] ) ) {
363
-			return self::$memo[ get_called_class() ][ __METHOD__ ];
362
+		if (isset(self::$memo[get_called_class()][__METHOD__])) {
363
+			return self::$memo[get_called_class()][__METHOD__];
364 364
 		}
365 365
 
366 366
 		$keys = array();
367 367
 
368
-		foreach ( $this->get_attribute_keys() as $key ) {
369
-			if ( $this->has_compute_method( $key ) ) {
368
+		foreach ($this->get_attribute_keys() as $key) {
369
+			if ($this->has_compute_method($key)) {
370 370
 				$keys[] = $key;
371 371
 			}
372 372
 		}
373 373
 
374
-		return self::$memo[ get_called_class() ][ __METHOD__ ] = $keys;
374
+		return self::$memo[get_called_class()][__METHOD__] = $keys;
375 375
 	}
376 376
 
377 377
 	/**
@@ -380,19 +380,19 @@  discard block
 block discarded – undo
380 380
 	 * @return array
381 381
 	 */
382 382
 	public function get_related_keys() {
383
-		if ( isset( self::$memo[ get_called_class() ][ __METHOD__ ] ) ) {
384
-			return self::$memo[ get_called_class() ][ __METHOD__ ];
383
+		if (isset(self::$memo[get_called_class()][__METHOD__])) {
384
+			return self::$memo[get_called_class()][__METHOD__];
385 385
 		}
386 386
 
387 387
 		$keys = array();
388 388
 
389
-		foreach ( $this->get_attribute_keys() as $key ) {
390
-			if ( $this->has_related_method( $key ) ) {
389
+		foreach ($this->get_attribute_keys() as $key) {
390
+			if ($this->has_related_method($key)) {
391 391
 				$keys[] = $key;
392 392
 			}
393 393
 		}
394 394
 
395
-		return self::$memo[ get_called_class() ][ __METHOD__ ] = $keys;
395
+		return self::$memo[get_called_class()][__METHOD__] = $keys;
396 396
 	}
397 397
 
398 398
 	/**
@@ -403,32 +403,32 @@  discard block
 block discarded – undo
403 403
 	public function serialize() {
404 404
 		$attributes = array();
405 405
 
406
-		if ( $this->visible ) {
406
+		if ($this->visible) {
407 407
 			// If visible attributes are set, we'll only reveal those.
408
-			foreach ( $this->visible as $key ) {
409
-				$attributes[ $key ] = $this->get_attribute( $key );
408
+			foreach ($this->visible as $key) {
409
+				$attributes[$key] = $this->get_attribute($key);
410 410
 			}
411
-		} elseif ( $this->hidden ) {
411
+		} elseif ($this->hidden) {
412 412
 			// If hidden attributes are set, we'll grab everything and hide those.
413
-			foreach ( $this->get_attribute_keys() as $key ) {
414
-				if ( ! in_array( $key, $this->hidden ) ) {
415
-					$attributes[ $key ] = $this->get_attribute( $key );
413
+			foreach ($this->get_attribute_keys() as $key) {
414
+				if (!in_array($key, $this->hidden)) {
415
+					$attributes[$key] = $this->get_attribute($key);
416 416
 				}
417 417
 			}
418 418
 		} else {
419 419
 			// If nothing is hidden/visible, we'll grab and reveal everything.
420
-			foreach ( $this->get_attribute_keys() as $key ) {
421
-				$attributes[ $key ] = $this->get_attribute( $key );
420
+			foreach ($this->get_attribute_keys() as $key) {
421
+				$attributes[$key] = $this->get_attribute($key);
422 422
 			}
423 423
 		}
424 424
 
425
-		return array_map( function ( $attribute ) {
426
-			if ( $attribute instanceof Serializes ) {
425
+		return array_map(function($attribute) {
426
+			if ($attribute instanceof Serializes) {
427 427
 				return $attribute->serialize();
428 428
 			}
429 429
 
430 430
 			return $attribute;
431
-		}, $attributes );
431
+		}, $attributes);
432 432
 	}
433 433
 
434 434
 	/**
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	public function sync_original() {
440 440
 		$this->original = $this->attributes;
441 441
 
442
-		if ( $this->attributes['object'] ) {
442
+		if ($this->attributes['object']) {
443 443
 			$this->original['object'] = clone $this->attributes['object'];
444 444
 		}
445 445
 
@@ -455,24 +455,24 @@  discard block
 block discarded – undo
455 455
 	 *
456 456
 	 * @return bool
457 457
 	 */
458
-	private function is_fillable( $name ) {
458
+	private function is_fillable($name) {
459 459
 		// If this model isn't guarded, everything is fillable.
460
-		if ( ! $this->is_guarded ) {
460
+		if (!$this->is_guarded) {
461 461
 			return true;
462 462
 		}
463 463
 
464 464
 		// If it's in the fillable array, then it's fillable.
465
-		if ( in_array( $name, $this->fillable ) ) {
465
+		if (in_array($name, $this->fillable)) {
466 466
 			return true;
467 467
 		}
468 468
 
469 469
 		// If it's explicitly guarded, then it's not fillable.
470
-		if ( in_array( $name, $this->guarded ) ) {
470
+		if (in_array($name, $this->guarded)) {
471 471
 			return false;
472 472
 		}
473 473
 
474 474
 		// If fillable hasn't been defined, then everything else fillable.
475
-		return ! $this->fillable;
475
+		return !$this->fillable;
476 476
 	}
477 477
 
478 478
 	/**
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
 	 *
485 485
 	 * @return $this
486 486
 	 */
487
-	private function override_wp_object( $value ) {
488
-		$this->attributes['object'] = $this->set_wp_object_constants( $value );
487
+	private function override_wp_object($value) {
488
+		$this->attributes['object'] = $this->set_wp_object_constants($value);
489 489
 
490 490
 		return $this;
491 491
 	}
@@ -499,19 +499,19 @@  discard block
 block discarded – undo
499 499
 	 * @throws LogicException
500 500
 	 */
501 501
 	private function create_wp_object() {
502
-		switch ( true ) {
502
+		switch (true) {
503 503
 			case $this instanceof UsesWordPressPost:
504
-				$object = new WP_Post( (object) array() );
504
+				$object = new WP_Post((object) array());
505 505
 				break;
506 506
 			case $this instanceof UsesWordPressTerm:
507
-				$object = new WP_Term( (object) array() );
507
+				$object = new WP_Term((object) array());
508 508
 				break;
509 509
 			default:
510 510
 				throw new LogicException;
511 511
 				break;
512 512
 		}
513 513
 
514
-		$this->attributes['object'] = $this->set_wp_object_constants( $object );
514
+		$this->attributes['object'] = $this->set_wp_object_constants($object);
515 515
 	}
516 516
 
517 517
 	/**
@@ -525,12 +525,12 @@  discard block
 block discarded – undo
525 525
 	 *
526 526
 	 * @return object
527 527
 	 */
528
-	protected function set_wp_object_constants( $object ) {
529
-		if ( $this instanceof UsesWordPressPost ) {
528
+	protected function set_wp_object_constants($object) {
529
+		if ($this instanceof UsesWordPressPost) {
530 530
 			$object->post_type = $this::get_post_type();
531 531
 		}
532 532
 
533
-		if ( $this instanceof UsesWordPressTerm ) {
533
+		if ($this instanceof UsesWordPressTerm) {
534 534
 			$object->taxonomy = $this::get_taxonomy();
535 535
 		}
536 536
 
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
 	 *
547 547
 	 * @return mixed
548 548
 	 */
549
-	public function __get( $name ) {
550
-		return $this->get_attribute( $name );
549
+	public function __get($name) {
550
+		return $this->get_attribute($name);
551 551
 	}
552 552
 
553 553
 	/**
@@ -559,19 +559,19 @@  discard block
 block discarded – undo
559 559
 	 *
560 560
 	 * @throws PropertyDoesNotExistException If property isn't found.
561 561
 	 */
562
-	public function get_attribute( $name ) {
563
-		if ( $method = $this->has_map_method( $name ) ) {
562
+	public function get_attribute($name) {
563
+		if ($method = $this->has_map_method($name)) {
564 564
 			$value = $this->attributes['object']->{$this->{$method}()};
565
-		} elseif ( $method = $this->has_compute_method( $name ) ) {
565
+		} elseif ($method = $this->has_compute_method($name)) {
566 566
 			$value = $this->{$method}();
567
-		} else if ( $method = $this->has_related_method( $name ) ) {
568
-			$value = $this->get_related( $this->{$method}()->get_sha() );
567
+		} else if ($method = $this->has_related_method($name)) {
568
+			$value = $this->get_related($this->{$method}()->get_sha());
569 569
 		} else {
570
-			if ( ! isset( $this->attributes['table'][ $name ] ) ) {
570
+			if (!isset($this->attributes['table'][$name])) {
571 571
 				throw new PropertyDoesNotExistException;
572 572
 			}
573 573
 
574
-			$value = $this->attributes['table'][ $name ];
574
+			$value = $this->attributes['table'][$name];
575 575
 		}
576 576
 
577 577
 		return $value;
@@ -586,10 +586,10 @@  discard block
 block discarded – undo
586 586
 	 *
587 587
 	 * @throws PropertyDoesNotExistException If property isn't found.
588 588
 	 */
589
-	public function get_original_attribute( $name ) {
590
-		$original = new static( $this->original );
589
+	public function get_original_attribute($name) {
590
+		$original = new static($this->original);
591 591
 
592
-		return $original->get_attribute( $name );
592
+		return $original->get_attribute($name);
593 593
 	}
594 594
 
595 595
 	/**
@@ -601,11 +601,11 @@  discard block
 block discarded – undo
601 601
 	 * @throws LogicException
602 602
 	 */
603 603
 	public function get_primary_id() {
604
-		if ( $this instanceof UsesWordPressPost ) {
604
+		if ($this instanceof UsesWordPressPost) {
605 605
 			return $this->get_underlying_wp_object()->ID;
606 606
 		}
607 607
 
608
-		if ( $this instanceof UsesWordPressTerm ) {
608
+		if ($this instanceof UsesWordPressTerm) {
609 609
 			return $this->get_underlying_wp_object()->term_id;
610 610
 		}
611 611
 
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 	 * @throws LogicException
623 623
 	 */
624 624
 	public function get_foreign_key() {
625
-		if ( $this instanceof UsesWordPressPost ) {
625
+		if ($this instanceof UsesWordPressPost) {
626 626
 			return 'post_id';
627 627
 		}
628 628
 
@@ -637,8 +637,8 @@  discard block
 block discarded – undo
637 637
 	 *
638 638
 	 * @return Model|Collection
639 639
 	 */
640
-	public function get_related( $sha ) {
641
-		return $this->related[ $sha ];
640
+	public function get_related($sha) {
641
+		return $this->related[$sha];
642 642
 	}
643 643
 
644 644
 	/**
@@ -649,12 +649,12 @@  discard block
 block discarded – undo
649 649
 	 *
650 650
 	 * @throws RuntimeException
651 651
 	 */
652
-	public function set_related( $sha, $target ) {
653
-		if ( ! ( $target instanceof Model ) && ! ( $target instanceof Collection ) ) {
652
+	public function set_related($sha, $target) {
653
+		if (!($target instanceof Model) && !($target instanceof Collection)) {
654 654
 			throw new RuntimeException;
655 655
 		}
656 656
 
657
-		$this->related[ $sha ] = $target;
657
+		$this->related[$sha] = $target;
658 658
 	}
659 659
 
660 660
 	/**
@@ -668,8 +668,8 @@  discard block
 block discarded – undo
668 668
 	 *
669 669
 	 * @return false|string
670 670
 	 */
671
-	protected function has_map_method( $name ) {
672
-		if ( method_exists( $this, $method = "map_{$name}" ) ) {
671
+	protected function has_map_method($name) {
672
+		if (method_exists($this, $method = "map_{$name}")) {
673 673
 			return $method;
674 674
 		}
675 675
 
@@ -686,8 +686,8 @@  discard block
 block discarded – undo
686 686
 	 *
687 687
 	 * @return false|string
688 688
 	 */
689
-	protected function has_compute_method( $name ) {
690
-		if ( method_exists( $this, $method = "compute_{$name}" ) ) {
689
+	protected function has_compute_method($name) {
690
+		if (method_exists($this, $method = "compute_{$name}")) {
691 691
 			return $method;
692 692
 		}
693 693
 
@@ -704,8 +704,8 @@  discard block
 block discarded – undo
704 704
 	 *
705 705
 	 * @return false|string
706 706
 	 */
707
-	protected function has_related_method( $name ) {
708
-		if ( method_exists( $this, $method = "related_{$name}" ) ) {
707
+	protected function has_related_method($name) {
708
+		if (method_exists($this, $method = "related_{$name}")) {
709 709
 			return $method;
710 710
 		}
711 711
 
@@ -723,10 +723,10 @@  discard block
 block discarded – undo
723 723
 	public function clear() {
724 724
 		$keys = $this->get_attribute_keys();
725 725
 
726
-		foreach ( $keys as $key ) {
726
+		foreach ($keys as $key) {
727 727
 			try {
728
-				$this->set_attribute( $key, null );
729
-			} catch ( GuardedPropertyException $e ) {
728
+				$this->set_attribute($key, null);
729
+			} catch (GuardedPropertyException $e) {
730 730
 				// We won't clear out guarded attributes.
731 731
 			}
732 732
 		}
@@ -760,13 +760,13 @@  discard block
 block discarded – undo
760 760
 	 * @return array
761 761
 	 */
762 762
 	protected function get_compute_methods() {
763
-		$methods = get_class_methods( get_called_class() );
764
-		$methods = array_filter( $methods, function ( $method ) {
765
-			return strrpos( $method, 'compute_', - strlen( $method ) ) !== false;
763
+		$methods = get_class_methods(get_called_class());
764
+		$methods = array_filter($methods, function($method) {
765
+			return strrpos($method, 'compute_', - strlen($method)) !== false;
766 766
 		} );
767
-		$methods = array_map( function ( $method ) {
768
-			return substr( $method, strlen( 'compute_' ) );
769
-		}, $methods );
767
+		$methods = array_map(function($method) {
768
+			return substr($method, strlen('compute_'));
769
+		}, $methods);
770 770
 
771 771
 		return $methods;
772 772
 	}
@@ -777,13 +777,13 @@  discard block
 block discarded – undo
777 777
 	 * @return array
778 778
 	 */
779 779
 	protected function get_related_methods() {
780
-		$methods = get_class_methods( get_called_class() );
781
-		$methods = array_filter( $methods, function ( $method ) {
782
-			return strrpos( $method, 'related_', - strlen( $method ) ) !== false;
780
+		$methods = get_class_methods(get_called_class());
781
+		$methods = array_filter($methods, function($method) {
782
+			return strrpos($method, 'related_', - strlen($method)) !== false;
783 783
 		} );
784
-		$methods = array_map( function ( $method ) {
785
-			return substr( $method, strlen( 'related_' ) );
786
-		}, $methods );
784
+		$methods = array_map(function($method) {
785
+			return substr($method, strlen('related_'));
786
+		}, $methods);
787 787
 
788 788
 		return $methods;
789 789
 	}
@@ -795,12 +795,12 @@  discard block
 block discarded – undo
795 795
 	 *
796 796
 	 * @return bool
797 797
 	 */
798
-	public function relation_is_filled( $relation ) {
798
+	public function relation_is_filled($relation) {
799 799
 		$sha = $this
800
-			->{$this->has_related_method( $relation )}()
800
+			->{$this->has_related_method($relation)}()
801 801
 			->get_sha();
802 802
 
803
-		return isset( $this->related[ $sha ] );
803
+		return isset($this->related[$sha]);
804 804
 	}
805 805
 
806 806
 	/**
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 	 *
819 819
 	 * @param bool $is_filling
820 820
 	 */
821
-	public function set_filling( $is_filling ) {
821
+	public function set_filling($is_filling) {
822 822
 		$this->filling = $is_filling;
823 823
 	}
824 824
 
@@ -831,8 +831,8 @@  discard block
 block discarded – undo
831 831
 	 *
832 832
 	 * @return HasMany
833 833
 	 */
834
-	protected function has_many( $class, $type, $foreign_key ) {
835
-		return new HasMany( $this, $class, $type, $foreign_key );
834
+	protected function has_many($class, $type, $foreign_key) {
835
+		return new HasMany($this, $class, $type, $foreign_key);
836 836
 	}
837 837
 
838 838
 	/**
@@ -844,16 +844,16 @@  discard block
 block discarded – undo
844 844
 	 *
845 845
 	 * @return HasMany
846 846
 	 */
847
-	protected function belongs_to_one( $class, $type, $local_key = '' ) {
848
-		return new BelongsToOne( $this, $class, $type, $local_key );
847
+	protected function belongs_to_one($class, $type, $local_key = '') {
848
+		return new BelongsToOne($this, $class, $type, $local_key);
849 849
 	}
850 850
 
851 851
 	/**
852 852
 	 * Sets up the memo array for the creating model.
853 853
 	 */
854 854
 	private function maybe_boot() {
855
-		if ( ! isset( self::$memo[ get_called_class() ] ) ) {
856
-			self::$memo[ get_called_class() ] = array();
855
+		if (!isset(self::$memo[get_called_class()])) {
856
+			self::$memo[get_called_class()] = array();
857 857
 		}
858 858
 	}
859 859
 
Please login to merge, or discard this patch.