LsfForm   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 9
c 0
b 0
f 0
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validationRules() 0 9 2
A errorMessages() 0 9 1
1
<?php
2
3
namespace Riclep\StoryblokForms\Blocks;
4
5
class LsfForm extends \Riclep\Storyblok\Block
6
{
7
	/**
8
	 * Returns all the validation rules for the fields in this Form
9
	 *
10
	 * @return array
11
	 */
12
	public function validationRules(): array
13
	{
14
		$rules = [];
15
16
		$this->fields->each(function ($field) use (&$rules) {
0 ignored issues
show
Bug Best Practice introduced by
The property fields does not exist on Riclep\StoryblokForms\Blocks\LsfForm. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
The method each() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
		$this->fields->/** @scrutinizer ignore-call */ 
17
                 each(function ($field) use (&$rules) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
17
			$rules = array_merge($rules, $field->validationRules() ?: []);
18
		});
19
20
		return $rules;
21
	}
22
23
	/**
24
	 * Returns all the error messages for the fields in this Form
25
	 *
26
	 * @return array
27
	 */
28
	public function errorMessages(): array
29
	{
30
		$errorMessages = [];
31
32
		$this->fields->each(function ($field) use (&$errorMessages) {
0 ignored issues
show
Bug Best Practice introduced by
The property fields does not exist on Riclep\StoryblokForms\Blocks\LsfForm. Since you implemented __get, consider adding a @property annotation.
Loading history...
33
			$errorMessages = array_merge($errorMessages, $field->errorMessages());
34
		});
35
36
		return $errorMessages;
37
	}
38
}