Test Failed
Push — ft/states ( eebc9c )
by Ben
29:42 queued 08:49
created

PreviewMode   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 6
c 0
b 0
f 0
dl 0
loc 19
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A check() 0 3 1
A fromRequest() 0 5 2
A __construct() 0 3 1
1
<?php
2
3
namespace Thinktomorrow\Chief\States\Publishable;
4
5
class PreviewMode
6
{
7
    private $active;
8
9
    public function __construct(bool $active)
10
    {
11
        $this->active = $active;
12
    }
13
14
    public static function fromRequest()
15
    {
16
        $active = (request()->has('preview-mode') && auth()->guard('chief')->check());
17
18
        return new static($active);
19
    }
20
21
    public function check(): bool
22
    {
23
        return $this->active;
24
    }
25
}
26