Passed
Pull Request — master (#51)
by
unknown
05:04
created

ContactFormSubmissionQuery::fromEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace rias\contactformextensions\elements\db;
4
5
use craft\elements\db\ElementQuery;
6
use craft\helpers\Db;
7
8
class ContactFormSubmissionQuery extends ElementQuery
9
{
10
    public $form;
11
    public $subject;
12
    public $fromName;
13
    public $fromEmail;
14
    public $attachments;
15
    public $message;
16
17
    public function form($value)
18
    {
19
        $this->form = $value;
20
21
        return $this;
22
    }
23
24
    public function subject($value)
25
    {
26
        $this->subject = $value;
27
28
        return $this;
29
    }
30
31
    public function fromName($value)
32
    {
33
        $this->fromName = $value;
34
35
        return $this;
36
    }
37
38
    public function fromEmail($value)
39
    {
40
        $this->fromEmail = $value;
41
42
        return $this;
43
    }
44
45
    public function attachments($value)
46
    {
47
        $this->attachments = $value;
48
49
        return $this;
50
    }
51
52
    public function message($value)
53
    {
54
        $this->message = $value;
55
56
        return $this;
57
    }
58
59
    protected function beforePrepare(): bool
60
    {
61
        // join in the products table
62
        $this->joinElementTable('contactform_submissions');
63
64
        // select the columns
65
        $this->query->select([
0 ignored issues
show
Bug introduced by
The method select() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
        $this->query->/** @scrutinizer ignore-call */ 
66
                      select([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
66
            'contactform_submissions.form',
67
            'contactform_submissions.subject',
68
            'contactform_submissions.fromName',
69
            'contactform_submissions.fromEmail',
70
            'contactform_submissions.attachments',
71
            'contactform_submissions.message',
72
        ]);
73
74
        if ($this->form) {
75
            $this->subQuery->andWhere(Db::parseParam('contactform_submissions.form', $this->form));
0 ignored issues
show
Bug introduced by
The method andWhere() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

75
            $this->subQuery->/** @scrutinizer ignore-call */ 
76
                             andWhere(Db::parseParam('contactform_submissions.form', $this->form));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
76
        }
77
78
        if ($this->subject) {
79
            $this->subQuery->andWhere(Db::parseParam('contactform_submissions.subject', $this->subject));
80
        }
81
82
        if ($this->fromName) {
83
            $this->subQuery->andWhere(Db::parseParam('contactform_submissions.fromName', $this->fromName));
84
        }
85
86
        if ($this->fromEmail) {
87
            $this->subQuery->andWhere(Db::parseParam('contactform_submissions.fromEmail', $this->fromEmail));
88
        }
89
90
        if ($this->attachments) {
91
            $this->subQuery->andWhere(Db::parseParam('contactform_submissions.attachments', $this->attachments));
92
        }
93
94
        if ($this->message) {
95
            $this->subQuery->andWhere(Db::parseParam('contactform_submissions.message', $this->message));
96
        }
97
98
        return parent::beforePrepare();
99
    }
100
}
101