@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | //Convert parametrs of old format to new format |
| 128 | 128 | if (!is_callable($text)) { |
| 129 | 129 | $optionTextValue = $text; |
| 130 | - $text = function ($model) use($optionTextValue) { |
|
| 130 | + $text = function($model) use($optionTextValue) { |
|
| 131 | 131 | if ($optionTextValue and isset($model->$optionTextValue)) { |
| 132 | 132 | return $model->$optionTextValue; |
| 133 | 133 | } elseif (method_exists($model, '__toString')) { |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $optionAttributeValue = $modelAttributeName($model); |
| 173 | 173 | } elseif ($modelAttributeName and isset($model->$modelAttributeName)) { |
| 174 | 174 | $optionAttributeValue = $model->$modelAttributeName; |
| 175 | - } elseif($optionAttributeName === 'value') { |
|
| 175 | + } elseif ($optionAttributeName === 'value') { |
|
| 176 | 176 | //For backward compatibility |
| 177 | 177 | if (method_exists($model, 'getKey')) { |
| 178 | 178 | $optionAttributeValue = $model->getKey(); |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | */ |
| 52 | 52 | public function getContent() |
| 53 | 53 | { |
| 54 | - $content = array_map(function ($content) { |
|
| 54 | + $content = array_map(function($content) { |
|
| 55 | 55 | return method_exists($content, '__toString') ? (string) $content : $content; |
| 56 | 56 | }, $this->value); |
| 57 | 57 | |
@@ -80,7 +80,6 @@ |
||
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Set which types of files are accepted by the file input |
| 83 | - |
|
| 84 | 83 | */ |
| 85 | 84 | public function accept() |
| 86 | 85 | { |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | $this->setOption('framework', $framework); |
| 354 | 354 | |
| 355 | 355 | $framework = $this->getFrameworkInstance($framework); |
| 356 | - $this->app->bind('former.framework', function ($app) use ($framework) { |
|
| 356 | + $this->app->bind('former.framework', function($app) use ($framework) { |
|
| 357 | 357 | return $framework; |
| 358 | 358 | }); |
| 359 | 359 | } |
@@ -373,9 +373,9 @@ discard block |
||
| 373 | 373 | //get interfaces of the given framework |
| 374 | 374 | $interfaces = class_exists($framework) ? class_implements($framework) : array(); |
| 375 | 375 | |
| 376 | - if(class_exists($formerClass)) { |
|
| 376 | + if (class_exists($formerClass)) { |
|
| 377 | 377 | $returnClass = $formerClass; |
| 378 | - } elseif(class_exists($framework) && isset($interfaces['Former\Interfaces\FrameworkInterface'])) { |
|
| 378 | + } elseif (class_exists($framework) && isset($interfaces['Former\Interfaces\FrameworkInterface'])) { |
|
| 379 | 379 | // We have some outside class, lets return it. |
| 380 | 380 | $returnClass = $framework; |
| 381 | 381 | } else { |
@@ -239,7 +239,7 @@ |
||
| 239 | 239 | */ |
| 240 | 240 | protected function prependWith($classes, $with) |
| 241 | 241 | { |
| 242 | - return array_map(function ($class) use ($with) { |
|
| 242 | + return array_map(function($class) use ($with) { |
|
| 243 | 243 | return $with.$class; |
| 244 | 244 | }, $classes); |
| 245 | 245 | } |
@@ -411,7 +411,7 @@ |
||
| 411 | 411 | $this->app['former']->labels[] = $name; |
| 412 | 412 | |
| 413 | 413 | // Count number of fields with the same ID |
| 414 | - $where = array_filter($this->app['former']->labels, function ($label) use ($name) { |
|
| 414 | + $where = array_filter($this->app['former']->labels, function($label) use ($name) { |
|
| 415 | 415 | return $label == $name; |
| 416 | 416 | }); |
| 417 | 417 | $unique = sizeof($where); |
@@ -258,49 +258,49 @@ |
||
| 258 | 258 | return $this; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - /** |
|
| 262 | - * Apply multiple rules passed as a string. |
|
| 263 | - * |
|
| 264 | - * @param $rules |
|
| 265 | - * @return $this |
|
| 266 | - */ |
|
| 267 | - public function rules($rules) |
|
| 268 | - { |
|
| 269 | - if (!is_array($rules)) { |
|
| 270 | - $rules = explode('|', $rules); |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - foreach ($rules as $rule) { |
|
| 274 | - $parameters = null; |
|
| 275 | - |
|
| 276 | - // If we have a rule with a value |
|
| 277 | - if (($colon = strpos($rule, ':')) !== false) { |
|
| 278 | - $rulename = substr($rule, 0, $colon) ; |
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * Regular expressions may contain commas and should not be divided by str_getcsv. |
|
| 282 | - * For regular expressions we are just using the complete expression as a parameter. |
|
| 283 | - */ |
|
| 284 | - if ($rulename !== 'regex') { |
|
| 285 | - $parameters = str_getcsv(substr($rule, $colon + 1)); |
|
| 286 | - } else { |
|
| 287 | - $parameters = [substr($rule, $colon + 1)]; |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - // Exclude unsupported rules |
|
| 292 | - $rule = is_numeric($colon) ? substr($rule, 0, $colon) : $rule; |
|
| 293 | - |
|
| 294 | - // Store processed rule in Former's array |
|
| 295 | - if (!isset($parameters)) { |
|
| 296 | - $parameters = array(); |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - call_user_func_array([$this, 'rule'], array_merge([$rule], $parameters)); |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - return $this; |
|
| 303 | - } |
|
| 261 | + /** |
|
| 262 | + * Apply multiple rules passed as a string. |
|
| 263 | + * |
|
| 264 | + * @param $rules |
|
| 265 | + * @return $this |
|
| 266 | + */ |
|
| 267 | + public function rules($rules) |
|
| 268 | + { |
|
| 269 | + if (!is_array($rules)) { |
|
| 270 | + $rules = explode('|', $rules); |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + foreach ($rules as $rule) { |
|
| 274 | + $parameters = null; |
|
| 275 | + |
|
| 276 | + // If we have a rule with a value |
|
| 277 | + if (($colon = strpos($rule, ':')) !== false) { |
|
| 278 | + $rulename = substr($rule, 0, $colon) ; |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * Regular expressions may contain commas and should not be divided by str_getcsv. |
|
| 282 | + * For regular expressions we are just using the complete expression as a parameter. |
|
| 283 | + */ |
|
| 284 | + if ($rulename !== 'regex') { |
|
| 285 | + $parameters = str_getcsv(substr($rule, $colon + 1)); |
|
| 286 | + } else { |
|
| 287 | + $parameters = [substr($rule, $colon + 1)]; |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + // Exclude unsupported rules |
|
| 292 | + $rule = is_numeric($colon) ? substr($rule, 0, $colon) : $rule; |
|
| 293 | + |
|
| 294 | + // Store processed rule in Former's array |
|
| 295 | + if (!isset($parameters)) { |
|
| 296 | + $parameters = array(); |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + call_user_func_array([$this, 'rule'], array_merge([$rule], $parameters)); |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + return $this; |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | 305 | /** |
| 306 | 306 | * Adds a label to the group/field |
@@ -275,7 +275,7 @@ |
||
| 275 | 275 | |
| 276 | 276 | // If we have a rule with a value |
| 277 | 277 | if (($colon = strpos($rule, ':')) !== false) { |
| 278 | - $rulename = substr($rule, 0, $colon) ; |
|
| 278 | + $rulename = substr($rule, 0, $colon); |
|
| 279 | 279 | |
| 280 | 280 | /** |
| 281 | 281 | * Regular expressions may contain commas and should not be divided by str_getcsv. |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | if (array_key_exists($name, $names)) { |
| 77 | 77 | $count = $names[$name] + 1; |
| 78 | 78 | $names[$name] = $count; |
| 79 | - return $name . '-' . $count; |
|
| 79 | + return $name.'-'.$count; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $names[$name] = 1; |
@@ -139,7 +139,7 @@ |
||
| 139 | 139 | $classes = array_intersect($classes, $this->fields); |
| 140 | 140 | |
| 141 | 141 | // Prepend field type |
| 142 | - $classes = array_map(function ($class) { |
|
| 142 | + $classes = array_map(function($class) { |
|
| 143 | 143 | return Str::startsWith($class, 'col') ? $class : 'input-'.$class; |
| 144 | 144 | }, $classes); |
| 145 | 145 | |