Passed
Push — develop ( df966a...03c672 )
by Richard
15:27
created

Input   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
eloc 11
c 2
b 0
f 0
dl 0
loc 48
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A validationRules() 0 2 1
A errorMessages() 0 2 1
A loopKey() 0 4 1
A getSizeAttribute() 0 6 3
1
<?php
2
3
namespace Riclep\StoryblokForms;
4
5
use Riclep\StoryblokForms\Traits\HasNames;
6
use Riclep\StoryblokForms\Traits\InFieldset;
7
use Riclep\StoryblokForms\Traits\ToJson;
8
9
class Input extends \Riclep\Storyblok\Block
10
{
11
	use HasNames, InFieldset, ToJson;
0 ignored issues
show
Bug introduced by
The trait Riclep\StoryblokForms\Traits\HasNames requires the property $input_name which is not provided by Riclep\StoryblokForms\Input.
Loading history...
Bug introduced by
The trait Riclep\StoryblokForms\Traits\ToJson requires the property $input_json_dot_name which is not provided by Riclep\StoryblokForms\Input.
Loading history...
12
13
	protected $key;
14
15
	/**
16
	 * @var string[] All the Validators for this Input
17
	 */
18
	protected $_casts = ['validators' => Validators::class];
19
20
	public function loopKey($key) {
21
		$this->key = $key;
22
23
		return $this;
24
	}
25
26
27
	/**
28
	 * All the Validation rules for this Input
29
	 *
30
	 * @return mixed
31
	 */
32
	public function validationRules() {
33
		return $this->validators->validationRules();
0 ignored issues
show
Bug Best Practice introduced by
The property validators does not exist on Riclep\StoryblokForms\Input. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
The method validationRules() 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

33
		return $this->validators->/** @scrutinizer ignore-call */ validationRules();

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...
34
	}
35
36
	/**
37
	 * All the error messages for this Input
38
	 *
39
	 * @return mixed
40
	 */
41
	public function errorMessages() {
42
		return $this->validators->errorMessages();
0 ignored issues
show
Bug Best Practice introduced by
The property validators does not exist on Riclep\StoryblokForms\Input. Since you implemented __get, consider adding a @property annotation.
Loading history...
43
	}
44
45
46
	/**
47
	 * Set’s the default Input size when not defined
48
	 *
49
	 * @return mixed|string
50
	 */
51
	public function getSizeAttribute() {
52
		if ($this->has('size')) {
53
			return $this->content()['size'] ?: 'full'; // TODO configure default size
54
		}
55
56
		return 'full'; // TODO configure default size
57
	}
58
}