Completed
Push — master ( b08b67...b98ff3 )
by greg
10:52 queued 07:23
created

MissionGameCondition::updateChrono()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace PlaygroundGame\Entity;
3
4
use Doctrine\ORM\Mapping as ORM;
5
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
6
use Doctrine\ORM\Mapping\PrePersist;
7
use Doctrine\ORM\Mapping\PreUpdate;
8
use Zend\InputFilter\InputFilter;
9
use Zend\InputFilter\InputFilterAwareInterface;
10
use Zend\InputFilter\InputFilterInterface;
11
12
/**
13
 * @ORM\Entity @HasLifecycleCallbacks
14
 * @ORM\Table(name="game_mission_game_condition")
15
 */
16
class MissionGameCondition implements InputFilterAwareInterface
17
{
18
19
    const NONE    = 0;
20
    const VICTORY = 1;
21
    const DEFEAT  = 2;
22
    const GREATER = 3;
23
    const LESS    = 4;
24
    /**
25
    * var $conditions
26
    * Tableau des types de conditions du jeu précendant pour passer au suivant.
27
    */
28
    public static $conditions = array(self::NONE     => 'none', // Go to next game
29
                                      self::VICTORY  => 'victory', // A victory is mandatory to go on
30
                                      self::DEFEAT   => 'defeat', // A defeat is mandatory to go on
31
                                      self::GREATER  => 'greater than x points', // x points to go on
32
                                      self::LESS     => 'less than x points' // < x points to go on
33
                                );
34
    protected $inputFilter;
35
    
36
    /**
37
     * @ORM\Id
38
     * @ORM\Column(type="integer");
39
     * @ORM\GeneratedValue(strategy="AUTO")
40
     */
41
    protected $id;
42
43
    /**
44
     * @ORM\ManyToOne(targetEntity="MissionGame", inversedBy="conditions")
45
     *
46
     **/
47
    protected $missionGame;
48
    
49
     /**
50
     * @ORM\Column(name="attribute", type="string", nullable=true)
51
     */
52
    protected $attribute;
53
54
    /**
55
     * @ORM\Column(name="comparison", type="string", nullable=true)
56
     */
57
    protected $comparison;
58
59
    /**
60
     * @ORM\Column(name="value", type="string", nullable=true)
61
     */
62
    protected $value;
63
64
    /**
65
     * @ORM\Column(name="created_at", type="datetime", nullable=true)
66
     */
67
    protected $createdAt;
68
69
    /**
70
     * @ORM\Column(name="updated_at", type="datetime", nullable=true)
71
     */
72
    protected $updatedAt;
73
74
    /**
75
     * Constructor
76
     */
77
    public function __construct()
78
    {
79
    }
80
81
     /**
82
     * @return the $id
83
     */
84
    public function getId()
85
    {
86
        return $this->id;
87
    }
88
89
    /**
90
     * @param field_type $id
91
     */
92
    public function setId($id)
93
    {
94
        $this->id = $id;
95
        
96
        return $this;
97
    }
98
99
    /**
100
     * @param $id
101
     * @return MissionGameCondition
102
     */
103
    public function setMissionGame($missionGame)
104
    {
105
        $this->missionGame = $missionGame;
106
107
        return $this;
108
    }
109
110
    /**
111
     * @return mixed
112
     */
113
    public function getMissionGame()
114
    {
115
        return $this->missionGame;
116
    }
117
118
     /**
119
     * @param $id
120
     * @return MissionGameCondition
121
     */
122
    public function setAttribute($attribute)
123
    {
124
        $this->attribute = $attribute;
125
126
        return $this;
127
    }
128
129
    /**
130
     * @return mixed
131
     */
132
    public function getAttribute()
133
    {
134
        return $this->attribute;
135
    }
136
137
     /**
138
     * @param $id
139
     * @return MissionGameCondition
140
     */
141
    public function setComparison($comparison)
142
    {
143
        $this->comparison = $comparison;
144
145
        return $this;
146
    }
147
148
    /**
149
     * @return mixed
150
     */
151
    public function getComparison()
152
    {
153
        return $this->comparison;
154
    }
155
156
     /**
157
     * @param $id
158
     * @return MissionGameCondition
159
     */
160
    public function setValue($value)
161
    {
162
        $this->value = $value;
163
164
        return $this;
165
    }
166
167
    /**
168
     * @return mixed
169
     */
170
    public function getValue()
171
    {
172
        return $this->value;
173
    }
174
175
    /** @PrePersist */
176
    public function createChrono()
177
    {
178
        $this->createdAt = new \DateTime("now");
179
        $this->updatedAt = new \DateTime("now");
180
    }
181
182
    /** @PreUpdate */
183
    public function updateChrono()
184
    {
185
        $this->updatedAt = new \DateTime("now");
186
    }
187
188
    public function setInputFilter(InputFilterInterface $inputFilter)
189
    {
190
        throw new \Exception("Not used");
191
    }
192
   
193
    public function getInputFilter()
194
    {
195
        if (! $this->inputFilter) {
196
            $inputFilter = new InputFilter();
197
            $this->inputFilter = $inputFilter;
198
        }
199
    
200
        return $this->inputFilter;
201
    }
202
}
203