Completed
Pull Request — 5.0 (#2162)
by Kevin
14:33
created

BooleanFormSubmissionField.php (1 issue)

Upgrade to new PHP Analysis Engine

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
use Kunstmaan\FormBundle\Form\ChoiceFormSubmissionType;
9
10
/**
11
 * The BooleanFormSubmissionField can be used to store one or more selected choices to a FormSubmission
12
 *
13
 * @ORM\Entity
14
 * @ORM\Table(name="kuma_boolean_form_submission_fields")
15
 */
16 View Code Duplication
class BooleanFormSubmissionField extends FormSubmissionField
0 ignored issues
show
This class seems to be duplicated in your project.

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.

Loading history...
17
{
18
19
    /**
20
     * @ORM\Column(name="bfsf_value", type="boolean", nullable=true)
21
     */
22
    protected $value;
23
24
    /**
25
     * Returns the default form type for this FormSubmissionField
26
     *
27
     * @return string
28
     */
29
    public function getDefaultAdminType()
30
    {
31
        return BooleanFormSubmissionType::class;
32
    }
33
34
    /**
35
     * Returns a string representation of this FormSubmissionField
36
     *
37
     * @return string
38
     */
39
    public function __toString()
40
    {
41
        $value = $this->getValue();
42
        if (empty($value)) {
43
            return "false";
44
        } else {
45
            return "true";
46
        }
47
    }
48
49
    /**
50
     * Get the value of this field
51
     *
52
     * @return boolean
53
     */
54
    public function getValue()
55
    {
56
        return $this->value;
57
    }
58
59
    /**
60
     * Set the value of this field
61
     *
62
     * @param boolean $value
63
     *
64
     * @return BooleanFormSubmissionField
65
     */
66
    public function setValue($value)
67
    {
68
        $this->value = $value;
69
70
        return $this;
71
    }
72
}
73