Issues (36)

src/Attributes/Rules/FileRules.php (1 issue)

Labels
Severity
1
<?php
2
3
4
namespace Larapie\Actions\Attributes\Rules;
5
6
7
trait FileRules
8
{
9
    public function image()
10
    {
11
        return $this->rule('image');
0 ignored issues
show
It seems like rule() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

11
        return $this->/** @scrutinizer ignore-call */ rule('image');
Loading history...
12
    }
13
14
    /*
15
     * Define dimensions with the properties as specified in the laravel documentation but in a kay value array
16
     * e.g. ["max_height" => 50]
17
     */
18
    public function dimensions(array $dimensions)
19
    {
20
        $dimensions = collect($dimensions)
21
            ->map(function ($key, $value) {
22
                return "$key=$value";
23
            })
24
            ->implode(',', '');
25
26
        return $this->rule('mimes:' . $dimensions);
27
    }
28
29
    public function mimes(string ...$extensions)
30
    {
31
        return $this->rule('mimes:' . implode(',', $extensions));
32
    }
33
34
    public function mimeTypes(string ...$types)
35
    {
36
        return $this->rule('mimetypes:' . implode(',', $types));
37
    }
38
39
    public function size(int $size)
40
    {
41
        return $this->rule("size:$size");
42
    }
43
}