Completed
Push — develop ( f8651f...893e32 )
by greg
02:30
created

Memory::getArrayCopy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace PlaygroundGame\Entity;
3
4
use Doctrine\Common\Collections\ArrayCollection;
5
use Doctrine\ORM\Mapping as ORM;
6
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
7
use Doctrine\ORM\Mapping\PrePersist;
8
use Doctrine\ORM\Mapping\PreUpdate;
9
10
use PlaygroundGame\Entity\Game;
11
12
use Zend\InputFilter\InputFilter;
13
use Zend\InputFilter\InputFilterAwareInterface;
14
use Zend\InputFilter\InputFilterInterface;
15
16
/**
17
 * @ORM\Entity @HasLifecycleCallbacks
18
 * @ORM\Table(name="game_memory")
19
 */
20
21 View Code Duplication
class Memory extends Game implements InputFilterAwareInterface
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...
22
{
23
    const CLASSTYPE = 'memory';
24
25
    /**
26
     * the cards associated with the game
27
     * @ORM\OneToMany(targetEntity="MemoryCard", mappedBy="game")
28
     */
29
    protected $cards;
30
31
    /**
32
     * @ORM\Column(name="back_image", type="string", length=255, nullable=true)
33
     */
34
    protected $backImage;
35
36
    /**
37
     * @ORM\Column(name="victory_conditions", type="integer", nullable=false)
38
     */
39
    protected $victoryConditions = 0;
40
41
    public function __construct()
42
    {
43
        parent::__construct();
44
        $this->setClassType(self::CLASSTYPE);
45
        $this->cards = new ArrayCollection();
46
    }
47
48
    /**
49
     * Gets the the cards associated with the game.
50
     *
51
     * @return mixed
52
     */
53
    public function getCards()
54
    {
55
        return $this->cards;
56
    }
57
58
    /**
59
     * Sets the the cards associated with the game.
60
     *
61
     * @param mixed $cards the cards
62
     *
63
     * @return self
64
     */
65
    protected function setCards($cards)
66
    {
67
        $this->cards = $cards;
68
69
        return $this;
70
    }
71
72
    /**
73
     * Add a card to the trading card.
74
     *
75
     *
76
     * @return void
77
     */
78
    public function addCard($card)
79
    {
80
        $this->cards[] = $card;
81
    }
82
83
    /**
84
     *
85
     * @return the $backImage
86
     */
87
    public function getBackImage()
88
    {
89
        return $this->backImage;
90
    }
91
92
    /**
93
     *
94
     * @param field_type $backImage
95
     */
96
    public function setBackImage($backImage)
97
    {
98
        $this->backImage = $backImage;
99
        
100
        return $this;
101
    }
102
103
    public function getVictoryConditions()
104
    {
105
        return $this->victoryConditions;
106
    }
107
108
    /**
109
     */
110
    public function setVictoryConditions($victoryConditions)
111
    {
112
        $this->victoryConditions = $victoryConditions;
113
114
        return $this;
115
    }
116
117
    /**
118
     * Convert the object to an array.
119
     *
120
     * @return array
121
     */
122
    public function getArrayCopy()
123
    {
124
        $obj_vars = parent::getArrayCopy();
125
        array_merge($obj_vars, get_object_vars($this));
126
127
        return $obj_vars;
128
    }
129
130
    public function setInputFilter(InputFilterInterface $inputFilter)
131
    {
132
        throw new \Exception("Not used");
133
    }
134
135
    public function getInputFilter()
136
    {
137
        if (!$this->inputFilter) {
138
            $inputFilter = new InputFilter();
0 ignored issues
show
Unused Code introduced by
$inputFilter is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
139
140
            $inputFilter = parent::getInputFilter();
141
142
            $this->inputFilter = $inputFilter;
143
        }
144
145
        return $this->inputFilter;
146
    }
147
}
148