Device::isPublic()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 3
eloc 2
nc 3
nop 0
crap 3
1
<?php
2
3
namespace PiFinder;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Device extends Model
8
{
9
    protected $fillable = ['ip', 'name', 'mac', 'public', 'group'];
10
11 2
    public function scopeOnHomePage($query)
12
    {
13 2
        return $query->where('public', 'true')
14 2
                     ->orWhere(function ($query) {
15 2
                         $query->where('public', 'auto')
16 2
                               ->whereNull('group');
17 2
                     });
18
    }
19
20 5
    public function isPublic()
21
    {
22 5
        return $this->public == 'true' || ($this->public == 'auto' && $this->group === null);
23
    }
24
}
25