Completed
Push — master ( aba493...5356ed )
by Ruud
315:38 queued 305:00
created

StringFormSubmissionField   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 53
loc 53
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultAdminType() 4 4 1
A __toString() 6 6 2
A getValue() 4 4 1
A setValue() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\StringFormSubmissionType;
8
9
/**
10
 * The StringFormSubmissionField can be used to store string values to a FormSubmission
11
 *
12
 * @ORM\Entity
13
 * @ORM\Table(name="kuma_string_form_submission_fields")
14
 */
15 View Code Duplication
class StringFormSubmissionField extends FormSubmissionField
0 ignored issues
show
Duplication introduced by
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...
16
{
17
    /**
18
     * @ORM\Column(name="sfsf_value", type="string")
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 StringFormSubmissionType::class;
30
    }
31
32
    /**
33
     * Return a string representation of this FormSubmissionField
34
     *
35
     * @return string
36
     */
37 1
    public function __toString()
38
    {
39 1
        $value = $this->getValue();
40
41 1
        return !empty($value) ? $value : '';
42
    }
43
44
    /**
45
     * Returns the current value of this field
46
     *
47
     * @return string
48
     */
49 3
    public function getValue()
50
    {
51 3
        return $this->value;
52
    }
53
54
    /**
55
     * Sets the current value of this field
56
     *
57
     * @param string $value
58
     *
59
     * @return StringFormSubmissionField
60
     */
61 2
    public function setValue($value)
62
    {
63 2
        $this->value = $value;
64
65 2
        return $this;
66
    }
67
}
68