LsfSelect   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 4
eloc 10
c 1
b 1
f 0
dl 0
loc 30
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A errorMessages() 0 18 4
1
<?php
2
3
namespace Riclep\StoryblokForms\Blocks;
4
5
use Illuminate\Support\Str;
6
use Riclep\StoryblokForms\MultiInput;
7
8
class LsfSelect extends MultiInput
9
{
10
	protected string $optionsName = 'options';
11
12
	protected string $type = 'multi-input';
13
14
15
	/**
16
	 * All the error messages for this Input
17
	 *
18
	 * @return mixed
19
	 */
20
	public function errorMessages(): mixed
21
	{
22
		$messages = $this->validators->errorMessages();
0 ignored issues
show
Bug Best Practice introduced by
The property validators does not exist on Riclep\StoryblokForms\Blocks\LsfSelect. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
The method errorMessages() 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

22
		/** @scrutinizer ignore-call */ 
23
  $messages = $this->validators->errorMessages();

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...
23
24
		/**
25
		 * Rewrite required to required_if for items inside conditional selects
26
		 */
27
		if ($this->parent() instanceof LsfConditionalSelect) {
28
			foreach ($messages as $key => $rule) {
29
				if (Str::endsWith($key, 'required')) {
30
					$messages[$key . '_if'] = $rule;
31
32
					unset($messages[$key]);
33
				}
34
			}
35
		}
36
37
		return $messages;
38
	}
39
}