SendingPerContent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 91.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 39
ccs 11
cts 12
cp 0.9167
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A calculate() 0 10 2
A uriKey() 0 3 1
A cacheFor() 0 3 1
1
<?php
2
3
namespace NovaFormEntries\Metrics;
4
5
use FormEntries\Models\FormEntry;
6
use Illuminate\Http\Request;
7
use Laravel\Nova\Metrics\Partition;
8
9
class SendingPerContent extends Partition
10
{
11
    /**
12
     * Calculate the value of the metric.
13
     *
14
     * @param \Illuminate\Http\Request $request
15
     * @return mixed
16
     */
17 1
    public function calculate(Request $request)
18
    {
19 1
        return $this->count($request, FormEntry::class, 'content_type')
20 1
                    ->label(function ($contentType) {
21 1
                        $class = \FormEntries\Forms\FormContent::getClassByType($contentType);
22 1
                        if ($class) {
23 1
                            return (new $class(FormEntry::query()->content($contentType)->first()))->formName();
24
                        }
25
26
                        return '-';
27 1
                    });
28
    }
29
30
    /**
31
     * Get the URI key for the metric.
32
     *
33
     * @return string
34
     */
35 1
    public function uriKey()
36
    {
37 1
        return 'form-entries-per-content-typeasd';
38
    }
39
40
    /**
41
     * Determine for how many minutes the metric should be cached.
42
     *
43
     * @return  \DateTimeInterface|\DateInterval|float|int
44
     */
45 1
    public function cacheFor()
46
    {
47 1
        return now()->addMinutes(30);
48
    }
49
}
50