Passed
Pull Request — 2.x (#1360)
by Harings
11:37
created

Files   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 35
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 3 1
A __construct() 0 20 2
1
<?php
2
3
namespace A17\Twill\View\Components;
4
5
use Illuminate\Support\Str;
6
7
class Files extends TwillFormComponent
8
{
9
10
    public $fieldNote;
11
    public $filesizeMax;
12
    public $buttonOnTop;
13
    public $itemLabel;
14
    public $note;
15
    public $max;
16
17
    public function __construct(
18
        $name,
19
        $label,
20
        $renderForBlocks = false,
21
        $renderForModal = false,
22
        $max = 1,
23
        $itemLabel = null,
24
        $note = null,
25
        $fieldNote = null,
26
        $filesizeMax = 0,
27
        $buttonOnTop = false
28
    ) {
29
        parent::__construct($name, $label, $renderForBlocks, $renderForModal);
30
        $itemLabel = $itemLabel ?? strtolower($label);
31
        $this->itemLabel = $itemLabel;
32
        $this->note = $note ?? 'Add' . ($max > 1 ? " up to $max $itemLabel" : ' one ' . Str::singular($itemLabel));
33
        $this->fieldNote = $fieldNote;
34
        $this->filesizeMax = $filesizeMax;
35
        $this->buttonOnTop = $buttonOnTop;
36
        $this->max = $max;
37
    }
38
39
    public function render()
40
    {
41
        return view('twill::partials.form._files');
42
    }
43
}
44