Completed
Push — master ( 3999b1...68e08f )
by Arjay
01:43
created

File::noImageText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Yajra\DataTables\Html\Editor\Fields;
4
5
/**
6
 * @see https://editor.datatables.net/reference/field/upload
7
 * @see https://editor.datatables.net/examples/advanced/upload.html
8
 * @see https://editor.datatables.net/examples/advanced/upload-many.html
9
 */
10
class File extends Field
11
{
12
    protected $type = 'upload';
13
14
    /**
15
     * @param string $name
16
     * @param string $label
17
     * @return \Yajra\DataTables\Html\Editor\Fields\Field|static
18
     */
19
    public static function make($name, $label = '')
20
    {
21
        return parent::make($name, $label)->displayFile()->clearText()->noImageText();
22
    }
23
24
    /**
25
     * Display image upon upload.
26
     *
27
     * @return $this
28
     */
29
    public function displayImage()
30
    {
31
        return $this->display("function (file_id) { return '<img src=\"' + file_id + '\"/>'; }");
32
    }
33
34
    /**
35
     * @param string $label
0 ignored issues
show
Bug introduced by
There is no parameter named $label. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
36
     * @return $this
37
     */
38
    public function display($value)
39
    {
40
        $this->attributes['display'] = $value;
41
42
        return $this;
43
    }
44
45
    /**
46
     * Display the file path.
47
     *
48
     * @return $this
49
     */
50
    public function displayFile()
51
    {
52
        return $this->display("function (file_id) { return file_id; }");
53
    }
54
55
    /**
56
     * @param string $value
57
     * @return $this
58
     */
59
    public function clearText($value = 'Clear')
60
    {
61
        $this->attributes['clearText'] = $value;
62
63
        return $this;
64
    }
65
66
    /**
67
     * @param string $value
68
     * @return $this
69
     */
70
    public function noImageText($value = 'No image')
71
    {
72
        $this->attributes['noImageText'] = $value;
73
74
        return $this;
75
    }
76
77
    /**
78
     * @param bool $state
79
     * @return $this
80
     */
81
    public function multiple($state = true)
82
    {
83
        if ($state) {
84
            $this->type('uploadMany');
85
        }
86
87
        return $this;
88
    }
89
}
90