Passed
Push — develop ( 10fa5a...842b91 )
by Richard
03:29
created

LsfSelect   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
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 32
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A errorMessages() 0 17 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
	/**
11
	 * @var string
12
	 */
13
	protected $optionsName = 'options';
14
15
	protected $type = 'multi-input';
16
17
18
	/**
19
	 * All the error messages for this Input
20
	 *
21
	 * @return mixed
22
	 */
23
	public function errorMessages() {
24
		$messages = $this->validators->errorMessages();
0 ignored issues
show
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

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