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

Files::render()   A

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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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