SendingTrend   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 45
ccs 12
cts 12
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A ranges() 0 6 1
A cacheFor() 0 3 1
A calculate() 0 3 1
A uriKey() 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\Trend;
8
9
class SendingTrend extends Trend
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->countByDays($request, FormEntry::class);
20
    }
21
22
    /**
23
     * Get the ranges available for the metric.
24
     *
25
     * @return array
26
     */
27 1
    public function ranges()
28
    {
29 1
        return [
30 1
            30 => '30 Days',
31 1
            60 => '60 Days',
32 1
            90 => '90 Days',
33 1
        ];
34
    }
35
36
    /**
37
     * Get the URI key for the metric.
38
     *
39
     * @return string
40
     */
41 1
    public function uriKey()
42
    {
43 1
        return 'form-entries-per-day';
44
    }
45
46
    /**
47
     * Determine for how many minutes the metric should be cached.
48
     *
49
     * @return  \DateTimeInterface|\DateInterval|float|int
50
     */
51 1
    public function cacheFor()
52
    {
53 1
        return now()->addMinutes(30);
54
    }
55
}
56