SendingPerContent::uriKey()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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