Completed
Push — master ( fe1366...05ac62 )
by Davide
08:29
created

Continent   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 2
eloc 11
dl 0
loc 40
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getContinents() 0 17 2
1
<?php
2
3
namespace DavideCasiraghi\LaravelEventsCalendar\Models;
4
5
use Illuminate\Support\Facades\Cache;
6
use Illuminate\Database\Eloquent\Model;
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 \DavideCasiraghi\LaravelEventsCalendar\Models\Continent
30
     */
31 4
    public static function getContinents($country_id)
32
    {
33
        // All the contients
34 4
        if ($country_id == null){
35 4
            $minutes = 15;
36
            $ret = Cache::remember('continents_list', $minutes, function () {
37 4
                return self::orderBy('name')->pluck('name', 'id');
38 4
            });
39
        }
40
        // The contient of a specified country
41
        else {
42
            $ret = self::firstWhere('id', $country_id);
43
                        //where('id', $country_id)->first();
44
                        //->pluck('name', 'id');
45
        }
46
            
47 4
        return $ret;
48
    }
49
}
50