@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @return $this |
| 22 | 22 | */ |
| 23 | - public function define( $alias, $definition ); |
|
| 23 | + public function define($alias, $definition); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Defines a new singleton on the Container. |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return $this |
| 35 | 35 | */ |
| 36 | - public function share( $alias, $definition ); |
|
| 36 | + public function share($alias, $definition); |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Fetches the value for the provided alias. |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return mixed |
| 44 | 44 | */ |
| 45 | - public function fetch( $alias ); |
|
| 45 | + public function fetch($alias); |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Checks whether the provided alias exists on the container. |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return bool |
| 53 | 53 | */ |
| 54 | - public function has( $alias ); |
|
| 54 | + public function has($alias); |
|
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * Removes the provided alias from the container. |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return bool |
| 62 | 62 | */ |
| 63 | - public function remove( $alias ); |
|
| 63 | + public function remove($alias); |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * Registers a service provider with the container. |
@@ -72,5 +72,5 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param ServiceProvider $provider |
| 74 | 74 | */ |
| 75 | - public function register( ServiceProvider $provider ); |
|
| 75 | + public function register(ServiceProvider $provider); |
|
| 76 | 76 | } |
@@ -13,21 +13,21 @@ |
||
| 13 | 13 | * |
| 14 | 14 | * @param bool $debug |
| 15 | 15 | */ |
| 16 | - public function set_debug( $debug ); |
|
| 16 | + public function set_debug($debug); |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Provides a method to register new scripts outside of the constructor. |
| 20 | 20 | * |
| 21 | 21 | * @param $script |
| 22 | 22 | */ |
| 23 | - public function register_script( $script ); |
|
| 23 | + public function register_script($script); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Provides a method to register new styles outside of the constructor. |
| 27 | 27 | * |
| 28 | 28 | * @param $style |
| 29 | 29 | */ |
| 30 | - public function register_style( $style ); |
|
| 30 | + public function register_style($style); |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Enqueues the web & shared scripts on the Register. |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @param string $vendor |
| 73 | 73 | */ |
| 74 | - public function set_vendor( $vendor ) { |
|
| 74 | + public function set_vendor($vendor) { |
|
| 75 | 75 | $this->vendor = $vendor; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @param int $version |
| 82 | 82 | */ |
| 83 | - public function set_version( $version ) { |
|
| 83 | + public function set_version($version) { |
|
| 84 | 84 | $this->version = $version; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -94,15 +94,15 @@ discard block |
||
| 94 | 94 | * @throws VersionNotSetException |
| 95 | 95 | */ |
| 96 | 96 | public function register() { |
| 97 | - if ( ! $this->vendor ) { |
|
| 97 | + if (!$this->vendor) { |
|
| 98 | 98 | throw new VendorNotSetException; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if ( ! $this->version ) { |
|
| 101 | + if (!$this->version) { |
|
| 102 | 102 | throw new VersionNotSetException; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - foreach ( $this->endpoints as $endpoint ) { |
|
| 105 | + foreach ($this->endpoints as $endpoint) { |
|
| 106 | 106 | register_rest_route( |
| 107 | 107 | $this->get_namespace(), |
| 108 | 108 | $endpoint->get_route(), |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | * @param array $options |
| 121 | 121 | * @param callable $callback |
| 122 | 122 | */ |
| 123 | - public function group( array $options, $callback ) { |
|
| 123 | + public function group(array $options, $callback) { |
|
| 124 | 124 | $router = new static; |
| 125 | 125 | |
| 126 | - call_user_func( $callback, $router ); |
|
| 126 | + call_user_func($callback, $router); |
|
| 127 | 127 | |
| 128 | - foreach ( $router->get_endpoints() as $endpoint ) { |
|
| 129 | - $this->endpoints[] = $this->set_options( $endpoint, $options ); |
|
| 128 | + foreach ($router->get_endpoints() as $endpoint) { |
|
| 129 | + $this->endpoints[] = $this->set_options($endpoint, $options); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
@@ -145,26 +145,26 @@ discard block |
||
| 145 | 145 | * @throws MissingArgumentException |
| 146 | 146 | * @throws InvalidArgumentException |
| 147 | 147 | */ |
| 148 | - public function __call( $name, $arguments ) { |
|
| 149 | - if ( ! in_array( $name, array_keys( $this->methods ) ) ) { |
|
| 148 | + public function __call($name, $arguments) { |
|
| 149 | + if (!in_array($name, array_keys($this->methods))) { |
|
| 150 | 150 | throw new UnknownMethodException; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // array_merge ensures we have 3 elements |
| 154 | - list( $route, $callback, $options ) = array_merge( $arguments, array( null, null, null ) ); |
|
| 154 | + list($route, $callback, $options) = array_merge($arguments, array(null, null, null)); |
|
| 155 | 155 | |
| 156 | - if ( ! $route || ! $callback ) { |
|
| 156 | + if (!$route || !$callback) { |
|
| 157 | 157 | throw new MissingArgumentException; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if ( ! is_callable( $callback ) ) { |
|
| 160 | + if (!is_callable($callback)) { |
|
| 161 | 161 | throw new InvalidArgumentException; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - $endpoint = new Endpoint( $route, $this->methods[ $name ], $callback ); |
|
| 164 | + $endpoint = new Endpoint($route, $this->methods[$name], $callback); |
|
| 165 | 165 | |
| 166 | - if ( $options && is_array( $options ) ) { |
|
| 167 | - $endpoint = $this->set_options( $endpoint, $options ); |
|
| 166 | + if ($options && is_array($options)) { |
|
| 167 | + $endpoint = $this->set_options($endpoint, $options); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | return $this->endpoints[] = $endpoint; |
@@ -181,17 +181,17 @@ discard block |
||
| 181 | 181 | * @return Endpoint |
| 182 | 182 | * @throws MalformedRouteException |
| 183 | 183 | */ |
| 184 | - protected function set_options( Endpoint $endpoint, array $options ) { |
|
| 185 | - if ( isset( $options['guard'] ) ) { |
|
| 186 | - $endpoint->set_guard( $options['guard'] ); |
|
| 184 | + protected function set_options(Endpoint $endpoint, array $options) { |
|
| 185 | + if (isset($options['guard'])) { |
|
| 186 | + $endpoint->set_guard($options['guard']); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if ( isset( $options['filter'] ) ) { |
|
| 190 | - $endpoint->set_filter( $options['filter'] ); |
|
| 189 | + if (isset($options['filter'])) { |
|
| 190 | + $endpoint->set_filter($options['filter']); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - if ( isset( $options['prefix'] ) ) { |
|
| 194 | - $endpoint->set_prefix( $options['prefix'] ); |
|
| 193 | + if (isset($options['prefix'])) { |
|
| 194 | + $endpoint->set_prefix($options['prefix']); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | return $endpoint; |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @throws MalformedRouteException |
| 67 | 67 | */ |
| 68 | - public function __construct( $route, $method, $callback ) { |
|
| 69 | - if ( ! Str::starts_with( $route, '/' ) || Str::ends_with( $route, '/' ) ) { |
|
| 68 | + public function __construct($route, $method, $callback) { |
|
| 69 | + if (!Str::starts_with($route, '/') || Str::ends_with($route, '/')) { |
|
| 70 | 70 | throw new MalformedRouteException; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | 85 | public function get_route() { |
| 86 | - return ( $this->prefix ?: '' ) . $this->route; |
|
| 86 | + return ($this->prefix ?: '') . $this->route; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | 'callback' => $this->callback, |
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | - if ( $this->guard ) { |
|
| 101 | - $options['permission_callback'] = array( $this->guard, 'authorized' ); |
|
| 100 | + if ($this->guard) { |
|
| 101 | + $options['permission_callback'] = array($this->guard, 'authorized'); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - if ( $this->filter ) { |
|
| 104 | + if ($this->filter) { |
|
| 105 | 105 | $options['args'] = $this->filter->rules(); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * |
| 116 | 116 | * @return $this |
| 117 | 117 | */ |
| 118 | - public function set_guard( GuardContract $guard ) { |
|
| 118 | + public function set_guard(GuardContract $guard) { |
|
| 119 | 119 | $this->guard = $guard; |
| 120 | 120 | |
| 121 | 121 | return $this; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * |
| 129 | 129 | * @return $this |
| 130 | 130 | */ |
| 131 | - public function set_filter( FilterContract $filter ) { |
|
| 131 | + public function set_filter(FilterContract $filter) { |
|
| 132 | 132 | $this->filter = $filter; |
| 133 | 133 | |
| 134 | 134 | return $this; |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | * @return $this |
| 143 | 143 | * @throws MalformedRouteException |
| 144 | 144 | */ |
| 145 | - public function set_prefix( $prefix ) { |
|
| 146 | - if ( ! Str::starts_with( $prefix, '/' ) || Str::ends_with( $prefix, '/' ) ) { |
|
| 145 | + public function set_prefix($prefix) { |
|
| 146 | + if (!Str::starts_with($prefix, '/') || Str::ends_with($prefix, '/')) { |
|
| 147 | 147 | throw new MalformedRouteException; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -825,7 +825,7 @@ |
||
| 825 | 825 | * @param string $type |
| 826 | 826 | * @param string $local_key |
| 827 | 827 | * |
| 828 | - * @return HasMany |
|
| 828 | + * @return BelongsToOne |
|
| 829 | 829 | */ |
| 830 | 830 | protected function belongs_to_one( $class, $type, $local_key = '' ) { |
| 831 | 831 | return new BelongsToOne( $this, $class, $type, $local_key ); |
@@ -113,15 +113,15 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | /** |
| 91 | 91 | * Gets the ID value for the target model to search by. |
| 92 | 92 | * |
| 93 | - * @return int|false |
|
| 93 | + * @return integer |
|
| 94 | 94 | * |
| 95 | 95 | * @throws LogicException |
| 96 | 96 | */ |
@@ -29,10 +29,10 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -159,7 +159,7 @@ |
||
| 159 | 159 | /** |
| 160 | 160 | * Fills the provided Model with attributes from its custom table. |
| 161 | 161 | * |
| 162 | - * @param Model|UsesCustomTable $model |
|
| 162 | + * @param Model $model |
|
| 163 | 163 | */ |
| 164 | 164 | protected function fill_table_attrs_from_table( Model $model ) { |
| 165 | 165 | $sql[] = "SELECT * FROM {$this->make_table_name( $model )}"; |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | - protected static function get_found( $class, $id ) { |
|
| 43 | - if ( isset( self::$found[ $class ][ $id ] ) ) { |
|
| 44 | - return self::$found[ $class ][ $id ]; |
|
| 42 | + protected static function get_found($class, $id) { |
|
| 43 | + if (isset(self::$found[$class][$id])) { |
|
| 44 | + return self::$found[$class][$id]; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | return false; |
@@ -88,15 +88,15 @@ discard block |
||
| 88 | 88 | * @param EntityManager $database |
| 89 | 89 | * @param string $class |
| 90 | 90 | */ |
| 91 | - public function __construct( EntityManager $database, $class ) { |
|
| 91 | + public function __construct(EntityManager $database, $class) { |
|
| 92 | 92 | $this->database = $database; |
| 93 | 93 | $this->class = $class; |
| 94 | 94 | $this->prefix = $database->get_prefix(); |
| 95 | 95 | $this->main = $database->get_main_query(); |
| 96 | 96 | $this->wpdb = $database->get_wpdb(); |
| 97 | 97 | |
| 98 | - if ( ! isset( self::$found[ $class ] ) ) { |
|
| 99 | - self::$found[ $class ] = array(); |
|
| 98 | + if (!isset(self::$found[$class])) { |
|
| 99 | + self::$found[$class] = array(); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return Model|WP_Error |
| 109 | 109 | */ |
| 110 | - abstract public function find( $id ); |
|
| 110 | + abstract public function find($id); |
|
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * Finds all the models of the repository class for the given params. |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @return Collection|WP_Error |
| 118 | 118 | */ |
| 119 | - abstract public function find_by( array $params = array() ); |
|
| 119 | + abstract public function find_by(array $params = array()); |
|
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | 122 | * Create and saves a new model of the repository class |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @return Model|WP_Error |
| 128 | 128 | */ |
| 129 | - abstract public function create( array $data = array() ); |
|
| 129 | + abstract public function create(array $data = array()); |
|
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | 132 | * Updates a model with its latest data. |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return Model|WP_Error |
| 137 | 137 | */ |
| 138 | - abstract public function persist( Model $model ); |
|
| 138 | + abstract public function persist(Model $model); |
|
| 139 | 139 | |
| 140 | 140 | /** |
| 141 | 141 | * Delete the provided Model. |
@@ -145,15 +145,15 @@ discard block |
||
| 145 | 145 | * |
| 146 | 146 | * @return Model|WP_Error |
| 147 | 147 | */ |
| 148 | - abstract public function delete( Model $model, $force = false ); |
|
| 148 | + abstract public function delete(Model $model, $force = false); |
|
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | 151 | * Registers the found Model with the EntityManager. |
| 152 | 152 | * |
| 153 | 153 | * @param Model $model |
| 154 | 154 | */ |
| 155 | - public function register_model( Model $model ) { |
|
| 156 | - self::$found[ $this->class ][ $model->get_primary_id() ] = $model; |
|
| 155 | + public function register_model(Model $model) { |
|
| 156 | + self::$found[$this->class][$model->get_primary_id()] = $model; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -161,21 +161,21 @@ discard block |
||
| 161 | 161 | * |
| 162 | 162 | * @param Model|UsesCustomTable $model |
| 163 | 163 | */ |
| 164 | - protected function fill_table_attrs_from_table( Model $model ) { |
|
| 165 | - $sql[] = "SELECT * FROM {$this->make_table_name( $model )}"; |
|
| 164 | + protected function fill_table_attrs_from_table(Model $model) { |
|
| 165 | + $sql[] = "SELECT * FROM {$this->make_table_name($model)}"; |
|
| 166 | 166 | $sql[] = "WHERE {$model->get_foreign_key()} = %d"; |
| 167 | 167 | |
| 168 | 168 | $sql = $this->wpdb->prepare( |
| 169 | - implode( ' ', $sql ), |
|
| 169 | + implode(' ', $sql), |
|
| 170 | 170 | $model->get_primary_id() |
| 171 | 171 | ); |
| 172 | 172 | |
| 173 | - $row = $this->wpdb->get_row( $sql, ARRAY_A ); |
|
| 173 | + $row = $this->wpdb->get_row($sql, ARRAY_A); |
|
| 174 | 174 | |
| 175 | 175 | $model->unguard(); |
| 176 | 176 | |
| 177 | - foreach ( $row as $key => $value ) { |
|
| 178 | - $model->set_attribute( $key, $value ); |
|
| 177 | + foreach ($row as $key => $value) { |
|
| 178 | + $model->set_attribute($key, $value); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | $model->reguard(); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @throws LogicException |
| 190 | 190 | */ |
| 191 | - protected function save_table_attributes_to_table( Model $model ) { |
|
| 191 | + protected function save_table_attributes_to_table(Model $model) { |
|
| 192 | 192 | throw new LogicException; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @throws LogicException |
| 201 | 201 | */ |
| 202 | - protected function delete_table_attributes_from_table( Model $model ) { |
|
| 202 | + protected function delete_table_attributes_from_table(Model $model) { |
|
| 203 | 203 | throw new LogicException; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * |
| 211 | 211 | * @return string |
| 212 | 212 | */ |
| 213 | - protected function make_table_name( UsesCustomTable $model ) { |
|
| 213 | + protected function make_table_name(UsesCustomTable $model) { |
|
| 214 | 214 | return "{$this->wpdb->prefix}{$this->prefix}_{$model::get_table_name()}"; |
| 215 | 215 | } |
| 216 | 216 | } |
@@ -239,7 +239,7 @@ |
||
| 239 | 239 | * |
| 240 | 240 | * @param Model $model |
| 241 | 241 | * |
| 242 | - * @return int|WP_Error |
|
| 242 | + * @return integer |
|
| 243 | 243 | */ |
| 244 | 244 | abstract protected function save_wp_object( Model $model ); |
| 245 | 245 | |
@@ -21,21 +21,21 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param int $id |
| 23 | 23 | */ |
| 24 | - public function find( $id ) { |
|
| 25 | - if ( $model = self::get_found( $this->class, $id ) ) { |
|
| 24 | + public function find($id) { |
|
| 25 | + if ($model = self::get_found($this->class, $id)) { |
|
| 26 | 26 | return $model; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - $object = $this->get_wp_object_by_id( $id ); |
|
| 29 | + $object = $this->get_wp_object_by_id($id); |
|
| 30 | 30 | |
| 31 | - if ( ! $object ) { |
|
| 31 | + if (!$object) { |
|
| 32 | 32 | return new WP_Error( |
| 33 | 33 | 'not_found', |
| 34 | - __( 'Entity not found', 'jaxion' ) |
|
| 34 | + __('Entity not found', 'jaxion') |
|
| 35 | 35 | ); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - return $this->make_model_from_wp_object( $object ); |
|
| 38 | + return $this->make_model_from_wp_object($object); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -45,15 +45,15 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return Collection |
| 47 | 47 | */ |
| 48 | - public function find_by( array $params = array() ) { |
|
| 48 | + public function find_by(array $params = array()) { |
|
| 49 | 49 | $collection = new Collection( |
| 50 | 50 | array(), |
| 51 | - array( 'model' => $this->class ) |
|
| 51 | + array('model' => $this->class) |
|
| 52 | 52 | ); |
| 53 | 53 | |
| 54 | - foreach ( $this->get_wp_objects_by_params( $params ) as $object ) { |
|
| 54 | + foreach ($this->get_wp_objects_by_params($params) as $object) { |
|
| 55 | 55 | $collection->add( |
| 56 | - $this->make_model_from_wp_object( $object ) |
|
| 56 | + $this->make_model_from_wp_object($object) |
|
| 57 | 57 | ); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -67,26 +67,26 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return Model|WP_Error |
| 69 | 69 | */ |
| 70 | - public function create( array $data = array() ) { |
|
| 70 | + public function create(array $data = array()) { |
|
| 71 | 71 | /** |
| 72 | 72 | * Model object. |
| 73 | 73 | * |
| 74 | 74 | * @var Model $model |
| 75 | 75 | */ |
| 76 | - $model = new $this->class( $data ); |
|
| 76 | + $model = new $this->class($data); |
|
| 77 | 77 | |
| 78 | - $id = $this->save_wp_object( $model ); |
|
| 78 | + $id = $this->save_wp_object($model); |
|
| 79 | 79 | |
| 80 | - if ( is_wp_error( $id ) ) { |
|
| 80 | + if (is_wp_error($id)) { |
|
| 81 | 81 | return $id; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $model->set_attribute( |
| 85 | 85 | 'object', |
| 86 | - $this->get_wp_object_by_id( $id ) |
|
| 86 | + $this->get_wp_object_by_id($id) |
|
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | - $this->save_table_attributes( $model ); |
|
| 89 | + $this->save_table_attributes($model); |
|
| 90 | 90 | $model->sync_original(); |
| 91 | 91 | |
| 92 | 92 | return $model; |
@@ -99,19 +99,19 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @return Model|WP_Error |
| 101 | 101 | */ |
| 102 | - public function persist( Model $model ) { |
|
| 103 | - $id = $this->save_wp_object( $model ); |
|
| 102 | + public function persist(Model $model) { |
|
| 103 | + $id = $this->save_wp_object($model); |
|
| 104 | 104 | |
| 105 | - if ( is_wp_error( $id ) ) { |
|
| 105 | + if (is_wp_error($id)) { |
|
| 106 | 106 | return $id; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $model->set_attribute( |
| 110 | 110 | 'object', |
| 111 | - $this->get_wp_object_by_id( $id ) |
|
| 111 | + $this->get_wp_object_by_id($id) |
|
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | - $this->save_table_attributes( $model ); |
|
| 114 | + $this->save_table_attributes($model); |
|
| 115 | 115 | $model->sync_original(); |
| 116 | 116 | |
| 117 | 117 | return $model; |
@@ -125,15 +125,15 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return Model|WP_Error |
| 127 | 127 | */ |
| 128 | - public function delete( Model $model, $force = false ) { |
|
| 129 | - $result = $this->delete_wp_object( $model, $force ); |
|
| 128 | + public function delete(Model $model, $force = false) { |
|
| 129 | + $result = $this->delete_wp_object($model, $force); |
|
| 130 | 130 | |
| 131 | - if ( is_wp_error( $result ) ) { |
|
| 131 | + if (is_wp_error($result)) { |
|
| 132 | 132 | return $result; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - if ( $force ) { |
|
| 136 | - $this->delete_table_attributes( $model ); |
|
| 135 | + if ($force) { |
|
| 136 | + $this->delete_table_attributes($model); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | return $model; |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @return Model |
| 148 | 148 | */ |
| 149 | - protected function make_model_from_wp_object( $object ) { |
|
| 150 | - if ( $model = self::get_found( $this->class, $this->get_wp_object_id( $object ) ) ) { |
|
| 149 | + protected function make_model_from_wp_object($object) { |
|
| 150 | + if ($model = self::get_found($this->class, $this->get_wp_object_id($object))) { |
|
| 151 | 151 | return $model; |
| 152 | 152 | } |
| 153 | 153 | |
@@ -156,12 +156,12 @@ discard block |
||
| 156 | 156 | * |
| 157 | 157 | * @var Model $model |
| 158 | 158 | */ |
| 159 | - $model = new $this->class( array( 'object' => $object ) ); |
|
| 159 | + $model = new $this->class(array('object' => $object)); |
|
| 160 | 160 | |
| 161 | - if ( $model instanceof UsesCustomTable ) { |
|
| 162 | - $this->fill_table_attrs_from_table( $model ); |
|
| 161 | + if ($model instanceof UsesCustomTable) { |
|
| 162 | + $this->fill_table_attrs_from_table($model); |
|
| 163 | 163 | } else { |
| 164 | - $this->fill_table_attrs_from_meta( $model ); |
|
| 164 | + $this->fill_table_attrs_from_meta($model); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | return $model; |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @param Model $model |
| 176 | 176 | */ |
| 177 | - protected function save_table_attributes( Model $model ) { |
|
| 178 | - if ( $model instanceof UsesCustomTable ) { |
|
| 179 | - $this->save_table_attributes_to_table( $model ); |
|
| 177 | + protected function save_table_attributes(Model $model) { |
|
| 178 | + if ($model instanceof UsesCustomTable) { |
|
| 179 | + $this->save_table_attributes_to_table($model); |
|
| 180 | 180 | } else { |
| 181 | - $this->save_table_attributes_to_meta( $model ); |
|
| 181 | + $this->save_table_attributes_to_meta($model); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
@@ -189,11 +189,11 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * @param Model $model |
| 191 | 191 | */ |
| 192 | - protected function delete_table_attributes( Model $model ) { |
|
| 193 | - if ( $model instanceof UsesCustomTable ) { |
|
| 194 | - $this->delete_table_attributes_from_table( $model ); |
|
| 192 | + protected function delete_table_attributes(Model $model) { |
|
| 193 | + if ($model instanceof UsesCustomTable) { |
|
| 194 | + $this->delete_table_attributes_from_table($model); |
|
| 195 | 195 | } else { |
| 196 | - $this->delete_table_attributes_from_meta( $model ); |
|
| 196 | + $this->delete_table_attributes_from_meta($model); |
|
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * |
| 206 | 206 | * @return string |
| 207 | 207 | */ |
| 208 | - protected function make_meta_key( $key ) { |
|
| 208 | + protected function make_meta_key($key) { |
|
| 209 | 209 | return "_{$this->prefix}_{$key}"; |
| 210 | 210 | } |
| 211 | 211 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @return object|false |
| 218 | 218 | */ |
| 219 | - abstract protected function get_wp_object_by_id( $id ); |
|
| 219 | + abstract protected function get_wp_object_by_id($id); |
|
| 220 | 220 | |
| 221 | 221 | /** |
| 222 | 222 | * Retrieves an array of WordPress objects by the provided params. |
@@ -225,14 +225,14 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * @return array |
| 227 | 227 | */ |
| 228 | - abstract protected function get_wp_objects_by_params( $params ); |
|
| 228 | + abstract protected function get_wp_objects_by_params($params); |
|
| 229 | 229 | |
| 230 | 230 | /** |
| 231 | 231 | * Fills the provided Model with its meta attributes. |
| 232 | 232 | * |
| 233 | 233 | * @param Model $model |
| 234 | 234 | */ |
| 235 | - abstract protected function fill_table_attrs_from_meta( Model $model ); |
|
| 235 | + abstract protected function fill_table_attrs_from_meta(Model $model); |
|
| 236 | 236 | |
| 237 | 237 | /** |
| 238 | 238 | * Save the provided WordPress object to the WordPress database. |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * |
| 242 | 242 | * @return int|WP_Error |
| 243 | 243 | */ |
| 244 | - abstract protected function save_wp_object( Model $model ); |
|
| 244 | + abstract protected function save_wp_object(Model $model); |
|
| 245 | 245 | |
| 246 | 246 | /** |
| 247 | 247 | * Saves the provided Model's changed table attributes |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * |
| 250 | 250 | * @param Model $model |
| 251 | 251 | */ |
| 252 | - abstract protected function save_table_attributes_to_meta( Model $model ); |
|
| 252 | + abstract protected function save_table_attributes_to_meta(Model $model); |
|
| 253 | 253 | |
| 254 | 254 | /** |
| 255 | 255 | * Delete the WordPress object associated with the |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @param Model $model |
| 260 | 260 | * @param bool $force |
| 261 | 261 | */ |
| 262 | - abstract protected function delete_wp_object( Model $model, $force = false ); |
|
| 262 | + abstract protected function delete_wp_object(Model $model, $force = false); |
|
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | 265 | * Delete all of the metadata associated with the object on |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * |
| 268 | 268 | * @param Model $model |
| 269 | 269 | */ |
| 270 | - abstract protected function delete_table_attributes_from_meta( Model $model ); |
|
| 270 | + abstract protected function delete_table_attributes_from_meta(Model $model); |
|
| 271 | 271 | |
| 272 | 272 | /** |
| 273 | 273 | * Gets the primary ID of the provided WordPress object. |
@@ -278,14 +278,14 @@ discard block |
||
| 278 | 278 | * |
| 279 | 279 | * @throws LogicException |
| 280 | 280 | */ |
| 281 | - protected function get_wp_object_id( $object ) { |
|
| 282 | - if ( $object instanceof WP_Post ) { |
|
| 281 | + protected function get_wp_object_id($object) { |
|
| 282 | + if ($object instanceof WP_Post) { |
|
| 283 | 283 | return $object->ID; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - if ( $object instanceof WP_Term || |
|
| 286 | + if ($object instanceof WP_Term || |
|
| 287 | 287 | // This is required for WP4.3- compatibility, when they returned stdClass. |
| 288 | - ( $object instanceof \stdClass && property_exists( $object, 'term_id' ) ) |
|
| 288 | + ($object instanceof \stdClass && property_exists($object, 'term_id')) |
|
| 289 | 289 | ) { |
| 290 | 290 | return $object->term_id; |
| 291 | 291 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @param array $rules |
| 26 | 26 | */ |
| 27 | - public function __construct( $rules = array() ) { |
|
| 27 | + public function __construct($rules = array()) { |
|
| 28 | 28 | $this->rules = $rules; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | public function rules() { |
| 40 | 40 | $args = array(); |
| 41 | 41 | |
| 42 | - foreach ( $this->rules as $arg => $validation ) { |
|
| 43 | - if ( ! $validation || ! is_string( $validation ) ) { |
|
| 42 | + foreach ($this->rules as $arg => $validation) { |
|
| 43 | + if (!$validation || !is_string($validation)) { |
|
| 44 | 44 | continue; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - $args[ $arg ] = $this->parse_validation( $validation ); |
|
| 47 | + $args[$arg] = $this->parse_validation($validation); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | return $args; |
@@ -59,43 +59,43 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @todo The next rule added needs to refactor this process. |
| 61 | 61 | */ |
| 62 | - protected function parse_validation( $validation ) { |
|
| 63 | - $validation = explode( '|', $validation ); |
|
| 62 | + protected function parse_validation($validation) { |
|
| 63 | + $validation = explode('|', $validation); |
|
| 64 | 64 | |
| 65 | 65 | $rules = array(); |
| 66 | 66 | |
| 67 | - foreach ( $validation as $rule ) { |
|
| 68 | - if ( 0 === strpos( $rule, 'default' ) ) { |
|
| 69 | - $rule_arr = explode( ':', $rule ); |
|
| 67 | + foreach ($validation as $rule) { |
|
| 68 | + if (0 === strpos($rule, 'default')) { |
|
| 69 | + $rule_arr = explode(':', $rule); |
|
| 70 | 70 | |
| 71 | - $rules['default'] = count( $rule_arr ) === 2 ? array_pop( $rule_arr ) : ''; |
|
| 71 | + $rules['default'] = count($rule_arr) === 2 ? array_pop($rule_arr) : ''; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( 0 === strpos( $rule, 'oneof' ) ) { |
|
| 75 | - list( $rule, $values ) = explode( ':', $rule ); |
|
| 74 | + if (0 === strpos($rule, 'oneof')) { |
|
| 75 | + list($rule, $values) = explode(':', $rule); |
|
| 76 | 76 | |
| 77 | - $values = explode( ',', $values ); |
|
| 78 | - $callback = function ( $value ) use ( $values ) { |
|
| 79 | - if ( in_array( $value, $values, true ) ) { |
|
| 77 | + $values = explode(',', $values); |
|
| 78 | + $callback = function($value) use ($values) { |
|
| 79 | + if (in_array($value, $values, true)) { |
|
| 80 | 80 | return true; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | return false; |
| 84 | 84 | }; |
| 85 | 85 | |
| 86 | - $rules['validate_callback'] = isset( $rules['validate_callback'] ) ? $this->add_callback( $rules['validate_callback'], $callback ) : $callback; |
|
| 86 | + $rules['validate_callback'] = isset($rules['validate_callback']) ? $this->add_callback($rules['validate_callback'], $callback) : $callback; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - switch ( $rule ) { |
|
| 89 | + switch ($rule) { |
|
| 90 | 90 | case 'required': |
| 91 | 91 | $rules['required'] = true; |
| 92 | 92 | break; |
| 93 | 93 | case 'integer': |
| 94 | - $callback = array( $this, 'validate_integer' ); |
|
| 95 | - $rules['validate_callback'] = isset( $rules['validate_callback'] ) ? $this->add_callback( $rules['validate_callback'], $callback ) : $callback; |
|
| 94 | + $callback = array($this, 'validate_integer'); |
|
| 95 | + $rules['validate_callback'] = isset($rules['validate_callback']) ? $this->add_callback($rules['validate_callback'], $callback) : $callback; |
|
| 96 | 96 | |
| 97 | - $callback = array( $this, 'make_integer' ); |
|
| 98 | - $rules['sanitize_callback'] = isset( $rules['sanitize_callback'] ) ? $this->add_callback( $rules['sanitize_callback'], $callback ) : $callback; |
|
| 97 | + $callback = array($this, 'make_integer'); |
|
| 98 | + $rules['sanitize_callback'] = isset($rules['sanitize_callback']) ? $this->add_callback($rules['sanitize_callback'], $callback) : $callback; |
|
| 99 | 99 | break; |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return bool |
| 112 | 112 | */ |
| 113 | - public function validate_integer( $value ) { |
|
| 114 | - return filter_var( $value, FILTER_VALIDATE_INT ) !== false; |
|
| 113 | + public function validate_integer($value) { |
|
| 114 | + return filter_var($value, FILTER_VALIDATE_INT) !== false; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @return int |
| 123 | 123 | */ |
| 124 | - public function make_integer( $value ) { |
|
| 124 | + public function make_integer($value) { |
|
| 125 | 125 | return (int) $value; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | * |
| 134 | 134 | * @return \Closure; |
| 135 | 135 | */ |
| 136 | - private function add_callback( $previous, $next ) { |
|
| 137 | - return function ( $value ) use ( $previous, $next ) { |
|
| 138 | - if ( call_user_func( $previous, $value ) ) { |
|
| 139 | - return call_user_func( $next, $value ); |
|
| 136 | + private function add_callback($previous, $next) { |
|
| 137 | + return function($value) use ($previous, $next) { |
|
| 138 | + if (call_user_func($previous, $value)) { |
|
| 139 | + return call_user_func($next, $value); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | return false; |