Passed
Push — master ( c6092e...2f4692 )
by Thomas
43s
created

RadioField   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 35
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A options() 0 6 1
A addOption() 0 10 2
1
<?php
2
3
namespace Webfactor\Laravel\Backpack\FluentSyntax\Fields;
4
5
use Webfactor\Laravel\Backpack\FluentSyntax\Contracts\CrudFieldAbstract;
6
use Webfactor\Laravel\Backpack\FluentSyntax\Traits\Defaultable;
7
use Webfactor\Laravel\Backpack\FluentSyntax\Traits\Prefixable;
8
use Webfactor\Laravel\Backpack\FluentSyntax\Traits\Suffixable;
9
10
class RadioField extends CrudFieldAbstract
11
{
12
    use Hintable, Defaultable;
13
14
    protected $type = 'radio';
15
16
    /**
17
     * Set options for the fields
18
     * @param  array  $options array of option
19
     * @return mixed
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use RadioField.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
20
     */
21
    public function options(array $options)
22
    {
23
      $this->options['options'] = $options;
24
25
      return $this;
26
    }
27
28
    /**
29
     * Add option to a field that is already set
30
     * @param string $value text that is shown to the user
31
     * @param null|string $key   the value of the new text
32
     */
33
    public function addOption($value, $key = null)
34
    {
35
      if(is_null($key)) {
36
        $this->options['options'][] = $value;
37
      } else {
38
        $this->options['options'][$key] = $value;
39
      }
40
41
      return $this;
42
    }
43
44
}
45