These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes; |
||
4 | |||
5 | use Doctrine\ORM\Mapping as ORM; |
||
6 | use Kunstmaan\FormBundle\Entity\FormSubmissionField; |
||
7 | use Kunstmaan\FormBundle\Form\BooleanFormSubmissionType; |
||
8 | |||
9 | /** |
||
10 | * The BooleanFormSubmissionField can be used to store one or more selected choices to a FormSubmission |
||
11 | * |
||
12 | * @ORM\Entity |
||
13 | * @ORM\Table(name="kuma_boolean_form_submission_fields") |
||
14 | */ |
||
15 | View Code Duplication | class BooleanFormSubmissionField extends FormSubmissionField |
|
0 ignored issues
–
show
|
|||
16 | { |
||
17 | /** |
||
18 | * @ORM\Column(name="bfsf_value", type="boolean", nullable=true) |
||
19 | */ |
||
20 | protected $value; |
||
21 | |||
22 | /** |
||
23 | * Returns the default form type for this FormSubmissionField |
||
24 | * |
||
25 | * @return string |
||
26 | */ |
||
27 | 1 | public function getDefaultAdminType() |
|
28 | { |
||
29 | 1 | return BooleanFormSubmissionType::class; |
|
30 | } |
||
31 | |||
32 | /** |
||
33 | * Returns a string representation of this FormSubmissionField |
||
34 | * |
||
35 | * @return string |
||
36 | */ |
||
37 | 2 | public function __toString() |
|
38 | { |
||
39 | 2 | $value = $this->getValue(); |
|
40 | 2 | if (empty($value)) { |
|
41 | 1 | return 'false'; |
|
42 | } |
||
43 | |||
44 | 2 | return 'true'; |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * Get the value of this field |
||
49 | * |
||
50 | * @return bool |
||
51 | */ |
||
52 | 3 | public function getValue() |
|
53 | { |
||
54 | 3 | return $this->value; |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * Set the value of this field |
||
59 | * |
||
60 | * @param bool $value |
||
61 | * |
||
62 | * @return BooleanFormSubmissionField |
||
63 | */ |
||
64 | 5 | public function setValue($value) |
|
65 | { |
||
66 | 5 | $this->value = $value; |
|
67 | |||
68 | 5 | return $this; |
|
69 | } |
||
70 | } |
||
71 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.