Field::render()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Saimondev03;
4
5
use Illuminate\Config\Repository;
6
use Illuminate\View\Component;
7
8
class Field extends Component
9
{
10
    /**
11
     * @var string
12
     */
13
    public $name;
14
15
    /**
16
     * @var bool
17
     */
18
    public $label;
19
20
    /**
21
     * @var false|mixed
22
     */
23
    public $required;
24
    /**
25
     * @var Repository
26
     */
27
    private $config;
28
29
    public function __construct(Repository $config, string $name, $required = false, $label = true)
30
    {
31
        $this->name = $name;
32
        $this->required = $required;
33
        $this->label = $label;
34
        $this->config = $config;
35
    }
36
37
    public function highlightsRequired()
38
    {
39
        return $this->config->get('form.highlights_requirement') === 'required' && $this->required;
40
    }
41
42
    public function highlightsOptional()
43
    {
44
        return $this->config->get('form.highlights_requirement') === 'optional' && ! $this->required;
45
    }
46
47
    public function highlightsLabel()
48
    {
49
        return $this->label === true;
50
    }
51
52
    public function render()
53
    {
54
        return view('saimondev03-form::field');
55
    }
56
}
57