@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function checkForCollectionExtensions() |
| 36 | 36 | { |
| 37 | - if (! Arr::hasMacro('fromDot') || ! Collection::hasMacro('fromDot')) { |
|
| 37 | + if (!Arr::hasMacro('fromDot') || !Collection::hasMacro('fromDot')) { |
|
| 38 | 38 | throw new \ErrorException( |
| 39 | 39 | 'Please register the CollectionsServiceProvider from the laravel-extend-collections package. ' . |
| 40 | 40 | 'Transformer requires the fromDot method for Illuminate Support Arr and Collection.' |
@@ -47,15 +47,15 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function registerTransformer() |
| 49 | 49 | { |
| 50 | - $this->app->singleton(Transformer::class, function () { |
|
| 50 | + $this->app->singleton(Transformer::class, function() { |
|
| 51 | 51 | return new Transformer(config('transformer.rule_packs', [])); |
| 52 | 52 | }); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | public function registerRequestTransformMacro() |
| 56 | 56 | { |
| 57 | - if (! Request::hasMacro('transform')) { |
|
| 58 | - Request::macro('transform', function ($rules = []) { |
|
| 57 | + if (!Request::hasMacro('transform')) { |
|
| 58 | + Request::macro('transform', function($rules = []) { |
|
| 59 | 59 | $this->replace( |
| 60 | 60 | app(Transformer::class) |
| 61 | 61 | ->transform($this->all(), $rules) |
@@ -100,7 +100,7 @@ |
||
| 100 | 100 | */ |
| 101 | 101 | protected function constructRule($rule, $arguments = []) : string |
| 102 | 102 | { |
| 103 | - return $rule . (! empty($arguments) ? ':' . implode(',', $arguments) : ''); |
|
| 103 | + return $rule . (!empty($arguments) ? ':' . implode(',', $arguments) : ''); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (! function_exists('str_putcsv')) { |
|
| 3 | +if (!function_exists('str_putcsv')) { |
|
| 4 | 4 | function str_putcsv($input, $delimiter = ',', $enclosure = '"') |
| 5 | 5 | { |
| 6 | 6 | $fp = fopen('php://temp', 'r+b'); |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | |
| 18 | 18 | public function provides() |
| 19 | 19 | { |
| 20 | - return array_filter(get_class_methods($this), function ($method) { |
|
| 20 | + return array_filter(get_class_methods($this), function($method) { |
|
| 21 | 21 | return substr($method, 0, 4) == 'rule'; |
| 22 | 22 | }); |
| 23 | 23 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function ruleNullWith($value, $check) |
| 39 | 39 | { |
| 40 | - return ! is_null($this->transformer->getValue($check)) ? null : $value; |
|
| 40 | + return !is_null($this->transformer->getValue($check)) ? null : $value; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /* |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function ruleDropWith($value, $check) |
| 47 | 47 | { |
| 48 | - $this->transformer->drop(! is_null($this->transformer->getValue($check))); |
|
| 48 | + $this->transformer->drop(!is_null($this->transformer->getValue($check))); |
|
| 49 | 49 | |
| 50 | 50 | return $value; |
| 51 | 51 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function ruleBailWith($value, $check) |
| 57 | 57 | { |
| 58 | - $this->transformer->bail(! is_null($this->transformer->getValue($check))); |
|
| 58 | + $this->transformer->bail(!is_null($this->transformer->getValue($check))); |
|
| 59 | 59 | |
| 60 | 60 | return $value; |
| 61 | 61 | } |
@@ -388,7 +388,7 @@ |
||
| 388 | 388 | /** |
| 389 | 389 | * Check if the Transformer instance has a given rule pack. |
| 390 | 390 | * |
| 391 | - * @param RulePack|String $rulePack |
|
| 391 | + * @param RulePack $rulePack |
|
| 392 | 392 | * @return bool |
| 393 | 393 | */ |
| 394 | 394 | public function hasRulePack($rulePack) : bool |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | $regex = str_replace(['.', '*'], ['\.', '([^\\.|]+)'], $fieldExpression); |
| 276 | 276 | preg_match_all("/({$regex})/", $this->dataKeysForRegex, $matches, PREG_SET_ORDER); |
| 277 | 277 | |
| 278 | - return array_reduce($matches, function ($results, $match) { |
|
| 278 | + return array_reduce($matches, function($results, $match) { |
|
| 279 | 279 | $results[$match[0]] = array_slice($match, 2); |
| 280 | 280 | |
| 281 | 281 | return $results; |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | */ |
| 324 | 324 | protected function validateRule($rule) : string |
| 325 | 325 | { |
| 326 | - if ( ! isset($this->ruleMethods[$this->getRuleMethod($rule)])) { |
|
| 326 | + if (!isset($this->ruleMethods[$this->getRuleMethod($rule)])) { |
|
| 327 | 327 | throw new InvalidRule($rule); |
| 328 | 328 | } |
| 329 | 329 | |
@@ -371,11 +371,11 @@ discard block |
||
| 371 | 371 | $rulePackClass = $this->getClassName($rulePack); |
| 372 | 372 | $rulePack = new $rulePackClass; |
| 373 | 373 | |
| 374 | - if ( ! ($rulePack instanceof RulePack)) { |
|
| 374 | + if (!($rulePack instanceof RulePack)) { |
|
| 375 | 375 | throw new UnexpectedValueException('RulePack must be an instance of ' . RulePack::class); |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if ( ! $this->hasRulePack($rulePack)) { |
|
| 378 | + if (!$this->hasRulePack($rulePack)) { |
|
| 379 | 379 | $this->rulePacks[$rulePackClass] = $rulePack->transformer($this); |
| 380 | 380 | |
| 381 | 381 | $ruleMethods = array_fill_keys($rulePack->provides(), $rulePackClass); |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | protected function replaceDataValue($field, $result) |
| 442 | 442 | { |
| 443 | 443 | $this->data = $this->data |
| 444 | - ->reject(function ($value, $key) use ($field) { |
|
| 444 | + ->reject(function($value, $key) use ($field) { |
|
| 445 | 445 | return preg_match("/^{$field}/", $key); |
| 446 | 446 | }) |
| 447 | 447 | ->merge(Arr::dot([$field => $result])); |