Passed
Pull Request — master (#778)
by Mark
03:00
created

SubmittedFormField::getExportValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\UserForms\Model\Submission;
4
5
use SilverStripe\ORM\DataObject;
6
use SilverStripe\UserForms\Model\Submission\SubmittedForm;
7
8
/**
9
 * Data received from a UserDefinedForm submission
10
 *
11
 * @package userforms
12
 */
13
class SubmittedFormField extends DataObject
14
{
15
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
16
        'Name' => 'Varchar',
17
        'Value' => 'Text',
18
        'Title' => 'Varchar(255)'
19
    ];
20
21
    private static $has_one = [
0 ignored issues
show
introduced by
The private property $has_one is not used, and could be removed.
Loading history...
22
        'Parent' => SubmittedForm::class
23
    ];
24
25
    private static $summary_fields = [
0 ignored issues
show
introduced by
The private property $summary_fields is not used, and could be removed.
Loading history...
26
        'Title' => 'Title',
27
        'CleanValue' => 'Value'
28
    ];
29
30
    private static $casting = [
0 ignored issues
show
introduced by
The private property $casting is not used, and could be removed.
Loading history...
31
        'CleanValue' => 'HTMLFragment'
32
    ];
33
34
    private static $table_name = 'SubmittedFormField';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
35
36
    /**
37
     * @param Member $member
0 ignored issues
show
Bug introduced by
The type SilverStripe\UserForms\Model\Submission\Member was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
38
     * @param array $context
39
     * @return boolean
40
     */
41
    public function canCreate($member = null, $context = [])
42
    {
43
        return $this->Parent()->canCreate();
0 ignored issues
show
Bug introduced by
The method Parent() does not exist on SilverStripe\UserForms\M...sion\SubmittedFormField. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

43
        return $this->/** @scrutinizer ignore-call */ Parent()->canCreate();
Loading history...
44
    }
45
46
    /**
47
     * @param Member $member
48
     *
49
     * @return boolean
50
     */
51
    public function canView($member = null)
52
    {
53
        return $this->Parent()->canView();
54
    }
55
56
    /**
57
     * @param Member $member
58
     *
59
     * @return boolean
60
     */
61
    public function canEdit($member = null)
62
    {
63
        return $this->Parent()->canEdit();
64
    }
65
66
    /**
67
     * @param Member $member
68
     *
69
     * @return boolean
70
     */
71
    public function canDelete($member = null)
72
    {
73
        return $this->Parent()->canDelete();
74
    }
75
76
    /**
77
     * Generate a clean value for the reports and email notifications.
78
     *
79
     * @return string
80
     */
81
    public function getCleanValue()
82
    {
83
        return $this->dbObject('Value')->RAW();
84
    }
85
86
    /**
87
     * Return the value of this submitted form field suitable for inclusion
88
     * into the CSV
89
     *
90
     * @return Text
0 ignored issues
show
Bug introduced by
The type SilverStripe\UserForms\Model\Submission\Text was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
91
     */
92
    public function getExportValue()
93
    {
94
        return $this->Value;
0 ignored issues
show
Bug Best Practice introduced by
The property Value does not exist on SilverStripe\UserForms\M...sion\SubmittedFormField. Since you implemented __get, consider adding a @property annotation.
Loading history...
95
    }
96
97
    /**
98
     * Find equivalent editable field for this submission.
99
     *
100
     * Note the field may have been modified or deleted from the original form
101
     * so this may not always return the data you expect. If you need to save
102
     * a particular state of editable form field at time of submission, copy
103
     * that value to the submission.
104
     *
105
     * @return EditableFormField
0 ignored issues
show
Bug introduced by
The type SilverStripe\UserForms\M...ssion\EditableFormField was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
106
     */
107
    public function getEditableField()
108
    {
109
        return $this->Parent()->Parent()->Fields()->filter([
110
            'Name' => $this->Name
0 ignored issues
show
Bug Best Practice introduced by
The property Name does not exist on SilverStripe\UserForms\M...sion\SubmittedFormField. Since you implemented __get, consider adding a @property annotation.
Loading history...
111
        ])->First();
112
    }
113
}
114