Continent   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getContinents() 0 8 1
1
<?php
2
3
namespace DavideCasiraghi\LaravelEventsCalendar\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Support\Facades\Cache;
7
8
class Continent extends Model
9
{
10
    /***************************************************************************/
11
    /**
12
     * The table associated with the model.
13
     *
14
     * @var string
15
     */
16
    protected $table = 'continents';
17
18
    /***************************************************************************/
19
20
    protected $fillable = [
21
        'name', 'code',
22
    ];
23
24
    /***************************************************************************/
25
26
    /**
27
     * Return all the continents ordered by name.
28
     *
29
     * @return iterable
30
     */
31 4
    public static function getContinents(): iterable
32
    {
33 4
        $seconds = 86400; // One day
34
        $ret = Cache::remember('continents_list', $seconds, function () {
35 4
            return self::orderBy('name')->pluck('name', 'id');
36 4
        });
37
38 4
        return $ret;
39
    }
40
}
41