@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @since 1.0.0 |
31 | 31 | */ |
32 | - public function get_all( array $args = array() ) { |
|
32 | + public function get_all(array $args = array()) { |
|
33 | 33 | |
34 | - $classes = array_diff_key( $this->classes, $this->objects ); |
|
34 | + $classes = array_diff_key($this->classes, $this->objects); |
|
35 | 35 | |
36 | - if ( ! empty( $classes ) ) { |
|
36 | + if ( ! empty($classes)) { |
|
37 | 37 | |
38 | 38 | $objects = WordPoints_Class_Registry::construct_with_args( |
39 | 39 | $classes |
@@ -49,40 +49,40 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * @since 1.0.0 |
51 | 51 | */ |
52 | - public function get( $slug, array $args = array() ) { |
|
52 | + public function get($slug, array $args = array()) { |
|
53 | 53 | |
54 | - if ( ! isset( $this->objects[ $slug ] ) ) { |
|
54 | + if ( ! isset($this->objects[$slug])) { |
|
55 | 55 | |
56 | - $object = parent::get( $slug, $args ); |
|
56 | + $object = parent::get($slug, $args); |
|
57 | 57 | |
58 | - if ( ! $object ) { |
|
58 | + if ( ! $object) { |
|
59 | 59 | return false; |
60 | 60 | } |
61 | 61 | |
62 | - $this->objects[ $slug ] = $object; |
|
62 | + $this->objects[$slug] = $object; |
|
63 | 63 | } |
64 | 64 | |
65 | - return $this->objects[ $slug ]; |
|
65 | + return $this->objects[$slug]; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @since 1.0.0 |
70 | 70 | */ |
71 | - public function register( $slug, $class, array $args = array() ) { |
|
71 | + public function register($slug, $class, array $args = array()) { |
|
72 | 72 | |
73 | - unset( $this->objects[ $slug ] ); |
|
73 | + unset($this->objects[$slug]); |
|
74 | 74 | |
75 | - return parent::register( $slug, $class, $args ); |
|
75 | + return parent::register($slug, $class, $args); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @since 1.0.0 |
80 | 80 | */ |
81 | - public function deregister( $slug ) { |
|
81 | + public function deregister($slug) { |
|
82 | 82 | |
83 | - parent::deregister( $slug ); |
|
83 | + parent::deregister($slug); |
|
84 | 84 | |
85 | - unset( $this->objects[ $slug ] ); |
|
85 | + unset($this->objects[$slug]); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return object|false The object or false if it is not registered. |
43 | 43 | */ |
44 | - public function get( $slug ); |
|
44 | + public function get($slug); |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Register a type of object. |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return bool Whether the class was registered successfully. |
56 | 56 | */ |
57 | - public function register( $slug, $class, array $args = array() ); |
|
57 | + public function register($slug, $class, array $args = array()); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Deregister a type of object |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @param string $slug The slug of the class to deregister. |
65 | 65 | */ |
66 | - public function deregister( $slug ); |
|
66 | + public function deregister($slug); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Check if a type of object is registered by its slug. |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return bool Whether the class is registered. |
76 | 76 | */ |
77 | - public function is_registered( $slug ); |
|
77 | + public function is_registered($slug); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // EOF |
@@ -17,14 +17,14 @@ |
||
17 | 17 | /** |
18 | 18 | * @since 1.0.0 |
19 | 19 | */ |
20 | - public function validate_value( $value ) { |
|
20 | + public function validate_value($value) { |
|
21 | 21 | |
22 | - wordpoints_int( $value ); |
|
22 | + wordpoints_int($value); |
|
23 | 23 | |
24 | - if ( false === $value ) { |
|
24 | + if (false === $value) { |
|
25 | 25 | return new WP_Error( |
26 | 26 | 'not_integer' |
27 | - , __( '%s must be an integer.', 'wordpoints' ) |
|
27 | + , __('%s must be an integer.', 'wordpoints') |
|
28 | 28 | ); |
29 | 29 | } |
30 | 30 |
@@ -20,12 +20,12 @@ |
||
20 | 20 | /** |
21 | 21 | * @since 1.0.0 |
22 | 22 | */ |
23 | - public function validate_value( $value ) { |
|
23 | + public function validate_value($value) { |
|
24 | 24 | |
25 | - if ( ! is_string( $value ) ) { |
|
25 | + if ( ! is_string($value)) { |
|
26 | 26 | return new WP_Error( |
27 | 27 | 'not_string' |
28 | - , __( '%s must be a text value.', 'wordpoints' ) |
|
28 | + , __('%s must be a text value.', 'wordpoints') |
|
29 | 29 | ); |
30 | 30 | } |
31 | 31 |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * |
43 | 43 | * @return mixed|WP_Error The validated value or a WP_Error on failure. |
44 | 44 | */ |
45 | - public function validate_value( $value ); |
|
45 | + public function validate_value($value); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // EOF |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return mixed The entity, or false if not found. |
82 | 82 | */ |
83 | - protected function get_entity( $id ) { |
|
83 | + protected function get_entity($id) { |
|
84 | 84 | |
85 | - $entity = call_user_func( $this->getter, $id ); |
|
85 | + $entity = call_user_func($this->getter, $id); |
|
86 | 86 | |
87 | - if ( ! $this->is_entity( $entity ) ) { |
|
87 | + if ( ! $this->is_entity($entity)) { |
|
88 | 88 | return false; |
89 | 89 | } |
90 | 90 | |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return bool Whether the passed value is an entity. |
102 | 102 | */ |
103 | - protected function is_entity( $entity ) { |
|
103 | + protected function is_entity($entity) { |
|
104 | 104 | |
105 | - if ( ! is_object( $entity ) && ! is_array( $entity ) ) { |
|
105 | + if ( ! is_object($entity) && ! is_array($entity)) { |
|
106 | 106 | return false; |
107 | 107 | } |
108 | 108 | |
109 | - return (bool) $this->get_entity_id( $entity ); |
|
109 | + return (bool) $this->get_entity_id($entity); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return mixed The value of the attribute of the entity. |
121 | 121 | */ |
122 | - protected function get_attr_value( $entity, $attr ) { |
|
122 | + protected function get_attr_value($entity, $attr) { |
|
123 | 123 | |
124 | - if ( is_array( $entity ) ) { |
|
125 | - if ( isset( $entity[ $attr ] ) ) { |
|
126 | - return $entity[ $attr ]; |
|
124 | + if (is_array($entity)) { |
|
125 | + if (isset($entity[$attr])) { |
|
126 | + return $entity[$attr]; |
|
127 | 127 | } |
128 | 128 | } else { |
129 | - if ( isset( $entity->{$attr} ) ) { |
|
129 | + if (isset($entity->{$attr} )) { |
|
130 | 130 | return $entity->{$attr}; |
131 | 131 | } |
132 | 132 | } |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return mixed The ID of the entity. |
145 | 145 | */ |
146 | - protected function get_entity_id( $entity ) { |
|
147 | - return $this->get_attr_value( $entity, $this->get_id_field() ); |
|
146 | + protected function get_entity_id($entity) { |
|
147 | + return $this->get_attr_value($entity, $this->get_id_field()); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @return mixed The human ID of the entity. |
162 | 162 | */ |
163 | - protected function get_entity_human_id( $entity ) { |
|
164 | - return $this->get_attr_value( $entity, $this->human_id_field ); |
|
163 | + protected function get_entity_human_id($entity) { |
|
164 | + return $this->get_attr_value($entity, $this->human_id_field); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // |
@@ -192,15 +192,15 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return string|int|float|false The human identifier for the entity, or false. |
194 | 194 | */ |
195 | - public function get_human_id( $id ) { |
|
195 | + public function get_human_id($id) { |
|
196 | 196 | |
197 | - $entity = $this->get_entity( $id ); |
|
197 | + $entity = $this->get_entity($id); |
|
198 | 198 | |
199 | - if ( ! $entity ) { |
|
199 | + if ( ! $entity) { |
|
200 | 200 | return false; |
201 | 201 | } |
202 | 202 | |
203 | - return $this->get_entity_human_id( $entity ); |
|
203 | + return $this->get_entity_human_id($entity); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return bool Whether or not an entity with that ID exists. |
214 | 214 | */ |
215 | - public function exists( $id ) { |
|
216 | - return (bool) $this->get_entity( $id ); |
|
215 | + public function exists($id) { |
|
216 | + return (bool) $this->get_entity($id); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -228,17 +228,17 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @return WordPoints_Entityish|false The child's object, or false if not found. |
230 | 230 | */ |
231 | - public function get_child( $child_slug ) { |
|
231 | + public function get_child($child_slug) { |
|
232 | 232 | |
233 | 233 | $children = wordpoints_entities()->children; |
234 | 234 | |
235 | - $child = $children->get( $this->slug, $child_slug ); |
|
235 | + $child = $children->get($this->slug, $child_slug); |
|
236 | 236 | |
237 | 237 | if ( |
238 | - isset( $this->the_value ) |
|
238 | + isset($this->the_value) |
|
239 | 239 | && $child instanceof WordPoints_Entity_ChildI |
240 | 240 | ) { |
241 | - $child->set_the_value_from_entity( $this ); |
|
241 | + $child->set_the_value_from_entity($this); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | return $child; |
@@ -260,20 +260,20 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @return bool Whether the value was set. |
262 | 262 | */ |
263 | - public function set_the_value( $value ) { |
|
263 | + public function set_the_value($value) { |
|
264 | 264 | |
265 | 265 | $this->the_value = $this->the_entity = null; |
266 | 266 | |
267 | - if ( $this->is_entity( $value ) ) { |
|
267 | + if ($this->is_entity($value)) { |
|
268 | 268 | |
269 | 269 | $entity = $value; |
270 | - $value = $this->get_entity_id( $value ); |
|
270 | + $value = $this->get_entity_id($value); |
|
271 | 271 | |
272 | 272 | } else { |
273 | 273 | |
274 | - $entity = $this->get_entity( $value ); |
|
274 | + $entity = $this->get_entity($value); |
|
275 | 275 | |
276 | - if ( ! $entity ) { |
|
276 | + if ( ! $entity) { |
|
277 | 277 | return false; |
278 | 278 | } |
279 | 279 | } |
@@ -293,8 +293,8 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return mixed The value of the attribute. |
295 | 295 | */ |
296 | - public function get_the_attr_value( $attr ) { |
|
297 | - return $this->get_attr_value( $this->the_entity, $attr ); |
|
296 | + public function get_the_attr_value($attr) { |
|
297 | + return $this->get_attr_value($this->the_entity, $attr); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @return string|int|float|null The human identifier for the entity, or null. |
319 | 319 | */ |
320 | 320 | public function get_the_human_id() { |
321 | - return $this->get_entity_human_id( $this->the_entity ); |
|
321 | + return $this->get_entity_human_id($this->the_entity); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @param string $entity_slug The slug of the entity type. |
54 | 54 | */ |
55 | - public function __construct( $entity_slug ) { |
|
55 | + public function __construct($entity_slug) { |
|
56 | 56 | |
57 | 57 | $this->entity_slug = $entity_slug; |
58 | - $this->entity_object = wordpoints_entities()->get( $this->entity_slug ); |
|
58 | + $this->entity_object = wordpoints_entities()->get($this->entity_slug); |
|
59 | 59 | |
60 | - parent::__construct( $this->entity_slug . '{}' ); |
|
60 | + parent::__construct($this->entity_slug.'{}'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return bool Whether the value was set successfully. |
82 | 82 | */ |
83 | - public function set_the_value( $values ) { |
|
83 | + public function set_the_value($values) { |
|
84 | 84 | |
85 | 85 | $this->the_entities = $this->the_value = array(); |
86 | 86 | |
87 | - if ( ! ( $this->entity_object instanceof WordPoints_Entity ) ) { |
|
87 | + if ( ! ($this->entity_object instanceof WordPoints_Entity)) { |
|
88 | 88 | return false; |
89 | 89 | } |
90 | 90 | |
91 | - foreach ( $values as $value ) { |
|
91 | + foreach ($values as $value) { |
|
92 | 92 | |
93 | 93 | $entity = clone $this->entity_object; |
94 | 94 | |
95 | - if ( $entity->set_the_value( $value ) ) { |
|
95 | + if ($entity->set_the_value($value)) { |
|
96 | 96 | $this->the_entities[] = $entity; |
97 | 97 | $this->the_value[] = $entity->get_the_id(); |
98 | 98 | } |
@@ -117,16 +117,16 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function get_title() { |
119 | 119 | |
120 | - if ( $this->entity_object ) { |
|
120 | + if ($this->entity_object) { |
|
121 | 121 | |
122 | 122 | return sprintf( |
123 | 123 | // translators: the singular name of an item |
124 | - __( '%s Collection', 'wordpoints' ) |
|
124 | + __('%s Collection', 'wordpoints') |
|
125 | 125 | , $this->entity_object->get_title() |
126 | 126 | ); |
127 | 127 | |
128 | 128 | } else { |
129 | - return __( 'Item Collection', 'wordpoints' ); |
|
129 | + return __('Item Collection', 'wordpoints'); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
@@ -78,9 +78,9 @@ |
||
78 | 78 | * |
79 | 79 | * @return bool Whether the value was set correctly. |
80 | 80 | */ |
81 | - public function set_the_value_from_entity( WordPoints_Entity $entity ) { |
|
81 | + public function set_the_value_from_entity(WordPoints_Entity $entity) { |
|
82 | 82 | |
83 | - $this->the_value = $entity->get_the_attr_value( $this->get_field() ); |
|
83 | + $this->the_value = $entity->get_the_attr_value($this->get_field()); |
|
84 | 84 | |
85 | 85 | return true; |
86 | 86 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * |
24 | 24 | * @return bool Whether the value was set successfully. |
25 | 25 | */ |
26 | - public function set_the_value_from_entity( WordPoints_Entity $entity ); |
|
26 | + public function set_the_value_from_entity(WordPoints_Entity $entity); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // EOF |