FormEntryResource   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 23
c 1
b 0
f 0
dl 0
loc 41
ccs 28
cts 28
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A cards() 0 5 1
A fields() 0 29 1
1
<?php
2
3
namespace NovaFormEntries;
4
5
use FormEntries\Models\FormEntry;
6
use Illuminate\Http\Request;
7
use Laravel\Nova\Fields\DateTime;
8
use Laravel\Nova\Fields\ID;
9
use Laravel\Nova\Fields\MorphTo;
10
use Laravel\Nova\Fields\Text;
11
use Laravel\Nova\Fields\Textarea;
12
use NovaFormEntries\Metrics\SendingPerContent;
13
use NovaFormEntries\Metrics\SendingTrend;
14
15
trait FormEntryResource
16
{
17
    abstract public function senderTypes(): array;
18
19 2
    public function fields(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

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

19
    public function fields(/** @scrutinizer ignore-unused */ Request $request)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
20
    {
21 2
        return [
22 2
            ID::make(),
23
24 2
            DateTime::make(__('Sent at'), 'created_at'),
25
26 2
            Text::make(__('Type'))
27 2
                ->displayUsing(function ($val, FormEntry $model) {
28 2
                    return $model->name;
29 2
                }),
30
31 2
            MorphTo::make(__('Sender'), 'sender')->types(
32 2
                $this->senderTypes()
33 2
            ),
34
35 2
            Text::make(__('IPs'))
36 2
                ->displayUsing(function ($val, FormEntry $model) {
37 2
                    return implode(', ', $model->requestIps());
38 2
                }),
39 2
            Text::make(__('User Agent'))
40 2
                ->displayUsing(function ($val, FormEntry $model) {
41 1
                    return $model->requestUserAgent();
42 2
                })->hideFromIndex(),
43
44 2
            Textarea::make(__('Content'), 'content')
45 2
                    ->resolveUsing(function ($val, FormEntry $model) {
46 1
                        return $model->content->stringify();
47 2
                    })->hideFromIndex(),
48 2
        ];
49
    }
50
51 1
    public function cards(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

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

51
    public function cards(/** @scrutinizer ignore-unused */ Request $request)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
    {
53 1
        return [
54 1
            new SendingTrend(),
55 1
            new SendingPerContent(),
56 1
        ];
57
    }
58
}
59