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

PreviewMode::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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