Completed
Push — develop ( a791bf...3a1732 )
by
unknown
08:09
created

PreviewFieldset   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 18.37 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
c 2
b 0
f 0
lcom 1
cbo 4
dl 9
loc 49
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getHydrator() 0 8 2
A init() 0 23 1
A setObject() 9 9 4

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
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 * @author    [email protected]
9
 */
10
11
namespace Jobs\Form;
12
13
use Core\Entity\DraftableEntityInterface;
14
use Core\Form\ViewPartialProviderInterface;
15
use Core\Form\ViewPartialProviderTrait;
16
use Zend\Form\Fieldset;
17
use Core\Entity\Hydrator\EntityHydrator;
18
19
/**
20
 * Defines the formular files of the 3rd formular for entering a job opening
21
 *
22
 * @package Jobs\Form
23
 */
24
class PreviewFieldset extends Fieldset implements ViewPartialProviderInterface
25
{
26
    use ViewPartialProviderTrait;
27
28
    protected $defaultPartial = 'jobs/form/preview';
29
30
    public function getHydrator()
31
    {
32
        if (!$this->hydrator) {
33
            $hydrator = new EntityHydrator();
34
            $this->setHydrator($hydrator);
35
        }
36
        return $this->hydrator;
37
    }
38
39
    public function init()
40
    {
41
        $this->setAttribute('id', 'jobpreview-fieldset');
42
43
        $this->add(
44
            array(
45
            'type' => 'infocheckbox',
46
            'name' => 'termsAccepted',
47
            'options' => array(
48
                'headline' => /*@translate*/ 'Terms and conditions',
49
                'long_label' => /*@translate*/ 'I have read the %s and accept it',
50
                'linktext' => /*@translate*/ 'terms an conditions',
51
                'route' => 'lang/content',
52
                'params' => array(
53
                    'view' => 'jobs-terms-and-conditions'
54
                )
55
            ),
56
            'attributes' => array(
57
                'data-trigger' => 'submit',
58
            ),
59
            )
60
        );
61
    }
62
63 View Code Duplication
    public function setObject($object)
0 ignored issues
show
Duplication introduced by
This method 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...
64
    {
65
        if ($object instanceof DraftableEntityInterface && !$object->isDraft()) {
66
            foreach ($this as $element) {
67
                $element->setAttribute('disabled', 'disabled');
68
            }
69
        }
70
        return parent::setObject($object);
71
    }
72
}
73