Passed
Pull Request — 2.x (#1360)
by Harings
11:27
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
        $max = 1,
21
        $itemLabel = null,
22
        $note = null,
23
        $fieldNote = null,
24
        $filesizeMax = 0,
25
        $buttonOnTop = false
26
    ) {
27
        parent::__construct($name, $label);
28
        $itemLabel = $itemLabel ?? strtolower($label);
29
        $this->itemLabel = $itemLabel;
30
        $this->note = $note ?? 'Add' . ($max > 1 ? " up to $max $itemLabel" : ' one ' . Str::singular($itemLabel));
31
        $this->fieldNote = $fieldNote;
32
        $this->filesizeMax = $filesizeMax;
33
        $this->buttonOnTop = $buttonOnTop;
34
        $this->max = $max;
35
    }
36
37
    public function render()
38
    {
39
        return view('twill::partials.form._files');
40
    }
41
}
42