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

PreviewMode::fromRequest()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
rs 10
cc 2
nc 2
nop 0
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