PendingForm   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 10
eloc 22
c 1
b 0
f 0
dl 0
loc 88
ccs 28
cts 28
cp 1
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A enableNotifications() 0 5 1
A disableNotifications() 0 5 1
A process() 0 3 1
A isShouldNotify() 0 3 1
A setNotifiableUsers() 0 5 1
A enableStoringData() 0 5 1
A isShouldStore() 0 3 1
A disableStoringData() 0 5 1
A __construct() 0 6 1
A setNotifiableEmails() 0 5 1
1
<?php
2
3
namespace FormEntries\Forms;
4
5
use FormEntries\Contracts\FormManipulationContract;
6
use FormEntries\Models\FormEntry;
7
use Illuminate\Http\Request;
8
9
class PendingForm implements FormManipulationContract
10
{
11
    protected Form $form;
12
13
    protected bool $shouldNotify;
14
15
    protected bool $shouldStore;
16
17
    /**
18
     * PendingForm constructor.
19
     *
20
     * @param $form
21
     */
22 12
    public function __construct(Form $form)
23
    {
24 12
        $this->form = $form;
25
26 12
        $this->shouldStore  = (bool) config('forms-entries.defaults.should_store');
27 12
        $this->shouldNotify = (bool) config('forms-entries.defaults.should_notify');
28
    }
29
30
    /**
31
     * @inheritDoc
32
     */
33 6
    public function enableStoringData(bool $shouldStore = true): static
34
    {
35 6
        $this->shouldStore = $shouldStore;
36
37 6
        return $this;
38
    }
39
40
    /**
41
     * @inheritDoc
42
     */
43 3
    public function disableStoringData(): static
44
    {
45 3
        $this->shouldStore = false;
46
47 3
        return $this;
48
    }
49
50 11
    public function isShouldStore(): bool
51
    {
52 11
        return $this->shouldStore;
53
    }
54
55
    /**
56
     * @inheritDoc
57
     */
58 7
    public function enableNotifications(bool $shouldNotify = true): static
59
    {
60 7
        $this->shouldNotify = $shouldNotify;
61
62 7
        return $this;
63
    }
64
65
    /**
66
     * @inheritDoc
67
     */
68 2
    public function disableNotifications(): static
69
    {
70 2
        $this->shouldNotify = false;
71
72 2
        return $this;
73
    }
74
75 11
    public function isShouldNotify(): bool
76
    {
77 11
        return $this->shouldNotify;
78
    }
79
80 2
    public function setNotifiableUsers(array|\Closure $notifiableUsers): static
81
    {
82 2
        $this->form->setNotifiableUsers($notifiableUsers);
83
84 2
        return $this;
85
    }
86
87 2
    public function setNotifiableEmails(array|\Closure $notifiableEmails): static
88
    {
89 2
        $this->form->setNotifiableEmails($notifiableEmails);
90
91 2
        return $this;
92
    }
93
94 10
    public function process(Request $request): FormEntry
95
    {
96 10
        return $this->form->process($request, $this);
97
    }
98
}
99