Completed
Push — master ( 6047a0...bb34d9 )
by greg
08:16 queued 03:34
created

Quiz::getNumberCorrectAnswersQuiz()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 7

Duplication

Lines 15
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 15
loc 15
rs 9.4285
cc 1
eloc 7
nc 1
nop 2
1
<?php
2
3
namespace PlaygroundGame\Service;
4
5
use PlaygroundGame\Entity\QuizReply;
6
use PlaygroundGame\Entity\QuizReplyAnswer;
7
use Zend\ServiceManager\ServiceManagerAwareInterface;
8
use PlaygroundGame\Mapper\GameInterface as GameMapperInterface;
9
use Zend\Stdlib\ErrorHandler;
10
11
class Quiz extends Game implements ServiceManagerAwareInterface
12
{
13
    /**
14
     * @var QuizMapperInterface
15
     */
16
    protected $quizMapper;
17
18
    /**
19
     * @var QuizAnswerMapperInterface
20
     */
21
    protected $quizAnswerMapper;
22
23
    /**
24
     * @var QuizQuestionMapperInterface
25
     */
26
    protected $quizQuestionMapper;
27
28
    /**
29
     * @var QuizReplyMapperInterface
30
     */
31
    protected $quizReplyMapper;
32
33
    /**
34
     * @var quizReplyAnswerMapper
35
     */
36
    protected $quizReplyAnswerMapper;
37
38
    /**
39
     *
40
     *
41
     * @param  array                  $data
42
     * @return \PlaygroundGame\Entity\Game
43
     */
44
    public function createQuestion(array $data)
45
    {
46
        $path = $this->getOptions()->getMediaPath() . DIRECTORY_SEPARATOR;
47
        $media_url = $this->getOptions()->getMediaUrl() . '/';
48
49
        $question  = new \PlaygroundGame\Entity\QuizQuestion();
50
        $form  = $this->getServiceManager()->get('playgroundgame_quizquestion_form');
51
        $form->bind($question);
52
        $form->setData($data);
53
54
        $quiz = $this->getGameMapper()->findById($data['quiz_id']);
55
        if (!$form->isValid()) {
56
            return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by PlaygroundGame\Service\Quiz::createQuestion of type PlaygroundGame\Entity\Game.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
57
        }
58
59
        $question->setQuiz($quiz);
60
61
        // If question is a prediction, no need to calculate max good answers
62
        if (!$question->getPrediction()) {
63
            // Max points and correct answers calculation for the question
64
            if (!$question = $this->calculateMaxAnswersQuestion($question)) {
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->calculateMaxAnswersQuestion($question); of type string adds the type string to the return on line 90 which is incompatible with the return type documented by PlaygroundGame\Service\Quiz::createQuestion of type PlaygroundGame\Entity\Game.
Loading history...
65
                return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by PlaygroundGame\Service\Quiz::createQuestion of type PlaygroundGame\Entity\Game.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
66
            }
67
        }
68
69
        // Max points and correct answers recalculation for the quiz
70
        $quiz = $this->calculateMaxAnswersQuiz($question->getQuiz());
71
72
        $this->getEventManager()->trigger(__FUNCTION__, $this, array('game' => $question, 'data' => $data));
73
        $this->getQuizQuestionMapper()->insert($question);
74
        $this->getEventManager()->trigger(__FUNCTION__.'.post', $this, array('game' => $question, 'data' => $data));
75
76 View Code Duplication
        if (!empty($data['upload_image']['tmp_name'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
77
            ErrorHandler::start();
78
            $data['upload_image']['name'] = $this->fileNewname(
79
                $path,
80
                $question->getId() . "-" . $data['upload_image']['name']
81
            );
82
            move_uploaded_file($data['upload_image']['tmp_name'], $path . $data['upload_image']['name']);
83
            $question->setImage($media_url . $data['upload_image']['name']);
84
            ErrorHandler::stop(true);
85
        }
86
87
        $this->getQuizQuestionMapper()->update($question);
88
        $this->getQuizMapper()->update($quiz);
89
90
        return $question;
91
    }
92
93
    /**
94
     * @param  array $data
95
     * @return \PlaygroundGame\Entity\Game
96
     */
97
    public function updateQuestion(array $data, $question)
98
    {
99
        $path = $this->getOptions()->getMediaPath() . DIRECTORY_SEPARATOR;
100
        $media_url = $this->getOptions()->getMediaUrl() . '/';
101
102
        $form  = $this->getServiceManager()->get('playgroundgame_quizquestion_form');
103
        $form->bind($question);
104
        $form->setData($data);
105
106
        if (!$form->isValid()) {
107
            return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by PlaygroundGame\Service\Quiz::updateQuestion of type PlaygroundGame\Entity\Game.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
108
        }
109
110
        // If question is a prediction, no need to calculate max good answers
111
        if (!$question->getPrediction()) {
112
            // Max points and correct answers calculation for the question
113
            if (!$question = $this->calculateMaxAnswersQuestion($question)) {
114
                return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by PlaygroundGame\Service\Quiz::updateQuestion of type PlaygroundGame\Entity\Game.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
115
            }
116
        }
117
118 View Code Duplication
        if (!empty($data['upload_image']['tmp_name'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
119
            ErrorHandler::start();
120
            $data['upload_image']['name'] = $this->fileNewname(
121
                $path,
122
                $question->getId() . "-" . $data['upload_image']['name']
123
            );
124
            move_uploaded_file($data['upload_image']['tmp_name'], $path . $data['upload_image']['name']);
125
            $question->setImage($media_url . $data['upload_image']['name']);
126
            ErrorHandler::stop(true);
127
        }
128
129 View Code Duplication
        if (isset($data['delete_image']) && empty($data['upload_image']['tmp_name'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
130
            ErrorHandler::start();
131
            $image = $question->getImage();
132
            $image = str_replace($media_url, '', $image);
133
            if (file_exists($path .$image)) {
134
                unlink($path .$image);
135
            }
136
            $question->setImage(null);
137
            ErrorHandler::stop(true);
138
        }
139
        
140
        $i = 0;
141
        foreach ($question->getAnswers() as $answer) {
142
            if (!empty($data['answers'][$i]['upload_image']['tmp_name'])) {
143
                ErrorHandler::start();
144
                $data['answers'][$i]['upload_image']['name'] = $this->fileNewname(
145
                    $path,
146
                    $question->getId() . "-" . $data['answers'][$i]['upload_image']['name']
147
                );
148
                move_uploaded_file(
149
                    $data['answers'][$i]['upload_image']['tmp_name'],
150
                    $path . $data['answers'][$i]['upload_image']['name']
151
                );
152
                $answer->setImage($media_url . $data['answers'][$i]['upload_image']['name']);
153
                ErrorHandler::stop(true);
154
            }
155
            $i++;
156
        }
157
158
        // Max points and correct answers recalculation for the quiz
159
        $quiz = $this->calculateMaxAnswersQuiz($question->getQuiz());
160
161
        // If the question was a pronostic, I update entries with the results !
162
        if ($question->getPrediction()) {
163
            $this->updatePrediction($question);
164
        }
165
166
        $this->getEventManager()->trigger(
167
            __FUNCTION__,
168
            $this,
169
            array('question' => $question, 'data' => $data)
170
        );
171
        $this->getQuizQuestionMapper()->update($question);
172
        $this->getEventManager()->trigger(
173
            __FUNCTION__.'.post',
174
            $this,
175
            array('question' => $question, 'data' => $data)
176
        );
177
178
        $this->getQuizMapper()->update($quiz);
179
180
        return $question;
181
    }
182
183
    public function findRepliesByGame($game)
184
    {
185
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');
186
        $qb = $em->createQueryBuilder();
187
        $qb->select('r')
188
            ->from('PlaygroundGame\Entity\QuizReply', 'r')
189
            ->innerJoin('r.entry', 'e')
190
            ->where('e.game = :game')
191
            ->setParameter('game', $game);
192
        $query = $qb->getQuery();
193
        
194
        $replies = $query->getResult();
195
196
        return $replies;
197
    }
198
199
    public function updatePrediction($question)
200
    {
201
        set_time_limit(0);
202
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');
203
        
204
        /* @var $dbal \Doctrine\DBAL\Connection */
205
        $dbal = $em->getConnection();
206
207
        $answers = $question->getAnswers($question->getQuiz());
208
209
        // I update all the answers with points and correctness
210
        // Very fast (native query inside)
211
        if ($question->getType() == 2){
212
            foreach ($answers as $answer) {
213
                $value = trim(strip_tags($answer->getAnswer()));
214
                $points = ($answer->getCorrect())? $answer->getPoints():0;
215
                $sql = "
216
                    UPDATE game_quiz_reply_answer AS ra 
217
                    SET ra.points=IF(ra.answer='". $value ."', ". $points .", ra.points), 
218
                        ra.correct = IF(ra.answer='". $value ."', ". $answer->getCorrect() .", ra.correct)
219
                    WHERE ra.question_id = " . $question->getId() ."
220
                ";
221
222
                $dbal->exec( $sql );
223
            }
224
225
        } else {
226
            foreach ($answers as $answer) {
227
                $points = ($answer->getCorrect())? $answer->getPoints():0;
228
                $sql = "
229
                    UPDATE game_quiz_reply_answer AS ra 
230
                    SET ra.points=" . $points .", 
231
                        ra.correct = " . $answer->getCorrect() ."
232
                    WHERE ra.question_id = ". $question->getId() ." 
233
                        AND ra.answer_id = ". $answer->getId() ."
234
                ";
235
236
                $dbal->exec( $sql );
237
            }
238
        }
239
240
        // Entry update with points. WINNER as to be calculated also !
241
        $sql = "
242
            UPDATE game_entry as e
243
            INNER JOIN
244
            (
245
               SELECT e.id, SUM(ra.points) as points, SUM(ra.correct) as correct
246
               FROM game_entry as e
247
               INNER JOIN game_quiz_reply AS r ON r.entry_id = e.id
248
               INNER JOIN game_quiz_reply_answer AS ra ON ra.reply_id = r.id
249
               GROUP BY e.id
250
            ) i ON e.id = i.id
251
            SET e.points = i.points 
252
            WHERE e.game_id = ". $question->getQuiz()->getId() . "
253
        ";
254
255
        $dbal->exec( $sql );
256
257
        $this->getEventManager()->trigger(
258
            __FUNCTION__.'.post',
259
            $this,
260
            array('question' => $question)
261
        );
262
    }
263
    /**
264
     * This function update the sort order of the questions in a Quiz
265
     * BEWARE : This function is time consuming (1s for 11 updates)
266
     * If you have many replies, switch to a  batch
267
     *
268
     * To improve performance, usage of DQL update
269
     * http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html
270
     *
271
     * @param  string $data
0 ignored issues
show
Bug introduced by
There is no parameter named $data. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
272
     * @return boolean
273
     */
274
    public function updatePredictionOld($question)
275
    {
276
        set_time_limit(0);
277
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');
278
279
        $replies = $this->findRepliesByGame($question->getQuiz());
280
281
        $answers = $question->getAnswers($question->getQuiz());
282
283
        $answersarray = array();
284
        foreach ($answers as $answer) {
285
            $answersarray[$answer->getId()] = $answer;
286
        }
287
288
        foreach ($replies as $reply) {
289
            $quizPoints = 0;
290
            $quizCorrectAnswers = 0;
291
292
            foreach ($reply->getAnswers() as $quizReplyAnswer) {
293
                if (2 != $question->getType() && $quizReplyAnswer->getQuestionId() === $question->getId()) {
294
                    if ($answersarray[$quizReplyAnswer->getAnswerId()]) {
295
                        $updatedAnswer = $answersarray[$quizReplyAnswer->getAnswerId()];
296
                        $quizReplyAnswer->setPoints($updatedAnswer->getPoints());
297
                        $quizReplyAnswer->setCorrect($updatedAnswer->getCorrect());
298
                        $q = $em->createQuery(
299
                            'update PlaygroundGame\Entity\QuizReplyAnswer a SET a.points = ' .
300
                            $updatedAnswer->getPoints() . ',a.correct=' . $updatedAnswer->getCorrect() .
301
                            ' WHERE a.id=' .$quizReplyAnswer->getId()
302
                        );
303
                        $q->execute();
304
                    }
305
                } elseif ($quizReplyAnswer->getQuestionId() === $question->getId()) {
306
                    // question is a textarea
307
                    // search for a matching answer
308
                    foreach ($answers as $answer) {
309
                        if (trim(strip_tags($answer->getAnswer())) == trim(
310
                            strip_tags($quizReplyAnswer->getAnswer())
311
                        )
312
                        ) {
313
                            $quizReplyAnswer->setPoints($answer->getPoints());
314
                            $quizReplyAnswer->setCorrect($answer->getCorrect());
315
                            $q = $em->createQuery(
316
                                'update PlaygroundGame\Entity\QuizReplyAnswer a SET a.points = ' .
317
                                $answer->getPoints() . ', a.correct='.$answer->getCorrect()
318
                                . ' WHERE a.id=' .$quizReplyAnswer->getId()
319
                            );
320
                            $q->execute();
321
                        } else {
322
                            $quizReplyAnswer->setPoints(0);
323
                            $quizReplyAnswer->setCorrect(false);
324
                            $q = $em->createQuery(
325
                                'update PlaygroundGame\Entity\QuizReplyAnswer a SET a.points = 0, a.correct = false WHERE a.id=' .
326
                                $quizReplyAnswer->getId()
327
                            );
328
                            $q->execute();
329
                        }
330
                    }
331
                }
332
333
                // The reply has been updated with correct answers and points for this question.
334
                // I count the whole set of points for this reply and update the entry
335
                if ($quizReplyAnswer->getCorrect()) {
336
                    $quizPoints += $quizReplyAnswer->getPoints();
337
                    $quizCorrectAnswers += $quizReplyAnswer->getCorrect();
338
                }
339
            }
340
            
341
            $winner = $this->isWinner($question->getQuiz(), $quizCorrectAnswers);
342
            $reply->getEntry()->setWinner($winner);
343
            $reply->getEntry()->setPoints($quizPoints);
344
            // The entry should be inactive : entry->setActive(false);
345
            $this->getEntryMapper()->update($reply->getEntry());
346
        }
347
348
        $this->getEventManager()->trigger(
349
            __FUNCTION__.'.post',
350
            $this,
351
            array('question' => $question)
352
        );
353
    }
354
355
    /**
356
     * This function update the sort order of the questions in a Quiz
357
     *
358
     * @param  string $data
359
     * @return boolean
360
     */
361
    public function sortQuestion($data)
362
    {
363
        $arr = explode(",", $data);
364
365
        foreach ($arr as $k => $v) {
366
            $question = $this->getQuizQuestionMapper()->findById($v);
367
            $question->setPosition($k);
368
            $this->getQuizQuestionMapper()->update($question);
369
        }
370
371
        return true;
372
    }
373
374
    /**
375
     * @return string
376
     */
377
    public function calculateMaxAnswersQuestion($question)
378
    {
379
        $question_max_points = 0;
380
        $question_max_correct_answers = 0;
381
        // Closed question : Only one answer allowed
382
        if ($question->getType() == 0) {
383
            foreach ($question->getAnswers() as $answer) {
384
                if ($answer->getPoints() > $question_max_points) {
385
                    $question_max_points = $answer->getPoints();
386
                }
387
                if ($answer->getCorrect() && $question_max_correct_answers==0) {
388
                    $question_max_correct_answers=1;
389
                }
390
            }
391
            if ($question_max_correct_answers == 0) {
392
                return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by PlaygroundGame\Service\Q...ulateMaxAnswersQuestion of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
393
            }
394
        // Closed question : Many answers allowed
395
        } elseif ($question->getType() == 1) {
396
            foreach ($question->getAnswers() as $answer) {
397
                $question_max_points += $answer->getPoints();
398
399
                if ($answer->getCorrect()) {
400
                    ++$question_max_correct_answers;
401
                }
402
            }
403
            if ($question_max_correct_answers == 0) {
404
                return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by PlaygroundGame\Service\Q...ulateMaxAnswersQuestion of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
405
            }
406
        // Not a question : A textarea to fill in
407
        } elseif ($question->getType() == 2) {
408
            $question_max_correct_answers = 0;
409
        }
410
411
        $question->setMaxPoints($question_max_points);
412
        $question->setMaxCorrectAnswers($question_max_correct_answers);
413
414
        return $question;
415
    }
416
417
    public function calculateMaxAnswersQuiz($quiz)
418
    {
419
        $question_max_points = 0;
420
        $question_max_correct_answers = 0;
421
        foreach ($quiz->getQuestions() as $question) {
422
            $question_max_points += $question->getMaxPoints();
423
            $question_max_correct_answers += $question->getMaxCorrectAnswers();
424
        }
425
        $quiz->setMaxPoints($question_max_points);
426
        $quiz->setMaxCorrectAnswers($question_max_correct_answers);
427
428
        return $quiz;
429
    }
430
431 View Code Duplication
    public function getNumberCorrectAnswersQuiz($user, $count = 'count')
0 ignored issues
show
Unused Code introduced by
The parameter $count is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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...
432
    {
433
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');
434
435
        $query = $em->createQuery(
436
            "SELECT COUNT(e.id) FROM PlaygroundGame\Entity\Entry e, PlaygroundGame\Entity\Game g
437
                WHERE e.user = :user
438
                AND g.classType = 'quiz'
439
                AND e.points > 0"
440
        );
441
        $query->setParameter('user', $user);
442
        $number = $query->getSingleScalarResult();
443
444
        return $number;
445
    }
446
447
    public function createQuizReply($data, $game, $user)
448
    {
449
        // Si mon nb de participation est < au nb autorisé, j'ajoute une entry + reponses au quiz et points
450
        $quizReplyMapper = $this->getQuizReplyMapper();
451
        $entryMapper = $this->getEntryMapper();
452
        $entry = $this->findLastActiveEntry($game, $user);
453
454
        if (!$entry) {
455
            return false;
456
        }
457
458
        $quizPoints          = 0;
459
        $quizCorrectAnswers  = 0;
460
        $maxCorrectAnswers = $game->getMaxCorrectAnswers();
461
        $totalQuestions = 0;
462
463
        $quizReply = $this->getQuizReplyMapper()->getLastGameReply($entry);
464
        if (!$quizReply) {
465
            $quizReply = new QuizReply();
466
        } else {
467
            $quizReplyAnswered = [];
468
            foreach ($quizReply->getAnswers() as $answer) {
469
                $quizReplyAnswered[$answer->getQuestionId()] = $answer;
470
                //$this->getQuizReplyAnswerMapper()->remove($answer);
471
            }
472
        }
473
        
474
        foreach ($data as $group) {
475
            foreach ($group as $q => $a) {
476
                if (strlen($q) > 5 && strpos($q, '-data', strlen($q) - 5) !== false) {
477
                    continue; // answer data is processed below
478
                }
479
                $question = $this->getQuizQuestionMapper()->findById((int) str_replace('q', '', $q));
480
                ++$totalQuestions;
481
                if (is_array($a)) {
482
                    foreach ($a as $k => $answer_id) {
483
                        $answer = $this->getQuizAnswerMapper()->findById($answer_id);
484 View Code Duplication
                        if ($answer) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
485
                            if(isset($quizReplyAnswered[$question->getId()])){
486
                                $this->getQuizReplyAnswerMapper()->remove($quizReplyAnswered[$question->getId()]);
487
                            }
488
489
                            $quizReplyAnswer = new QuizReplyAnswer();
490
                            $quizReplyAnswer->setAnswer($answer->getAnswer());
491
                            $quizReplyAnswer->setAnswerId($answer_id);
492
                            $quizReplyAnswer->setQuestion($question->getQuestion());
493
                            $quizReplyAnswer->setQuestionId($question->getId());
494
                            $quizReplyAnswer->setPoints($answer->getPoints());
495
                            $quizReplyAnswer->setCorrect($answer->getCorrect());
496
497
                            $quizReply->addAnswer($quizReplyAnswer);
498
                            
499
                            $quizPoints += $answer->getPoints();
500
                            $quizCorrectAnswers += $answer->getCorrect();
501
502
                            if (isset($group[$q.'-'.$answer_id.'-data'])) {
503
                                $quizReplyAnswer->setAnswerData($group[$q.'-'.$answer_id.'-data']);
504
                            }
505
                        }
506
                    }
507
                } elseif ($question->getType() == 0 || $question->getType() == 1) {
508
                    ++$totalQuestions;
509
                    $answer = $this->getQuizAnswerMapper()->findById($a);
510 View Code Duplication
                    if ($answer) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
511
                        if(isset($quizReplyAnswered[$question->getId()])){
512
                            $this->getQuizReplyAnswerMapper()->remove($quizReplyAnswered[$question->getId()]);
513
                        }
514
                        $quizReplyAnswer = new QuizReplyAnswer();
515
                        $quizReplyAnswer->setAnswer($answer->getAnswer());
516
                        $quizReplyAnswer->setAnswerId($a);
517
                        $quizReplyAnswer->setQuestion($question->getQuestion());
518
                        $quizReplyAnswer->setQuestionId($question->getId());
519
                        $quizReplyAnswer->setPoints($answer->getPoints());
520
                        $quizReplyAnswer->setCorrect($answer->getCorrect());
521
522
                        $quizReply->addAnswer($quizReplyAnswer);
523
524
                        $quizPoints += $answer->getPoints();
525
                        $quizCorrectAnswers += $answer->getCorrect();
526
                        if (isset($group[$q.'-'.$a.'-data'])) {
527
                            $quizReplyAnswer->setAnswerData($group[$q.'-'.$a.'-data']);
528
                        }
529
                    }
530
                } elseif ($question->getType() == 2) {
531
                    ++$totalQuestions;
532
                    if(isset($quizReplyAnswered[$question->getId()])){
533
                        $this->getQuizReplyAnswerMapper()->remove($quizReplyAnswered[$question->getId()]);
534
                    }
535
                    $quizReplyAnswer = new QuizReplyAnswer();
536
                    $quizReplyAnswer->setAnswer($a);
537
                    $quizReplyAnswer->setAnswerId(0);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a object<PlaygroundGame\Entity\unknown_type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
538
                    $quizReplyAnswer->setQuestion($question->getQuestion());
539
                    $quizReplyAnswer->setQuestionId($question->getId());
540
                    $quizReplyAnswer->setPoints(0);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a object<PlaygroundGame\Entity\field_type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
541
                    $quizReplyAnswer->setCorrect(0);
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a object<PlaygroundGame\Entity\unknown_type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
542
543
                    $quizReply->addAnswer($quizReplyAnswer);
544
545
                    $quizPoints += 0;
546
                    $quizCorrectAnswers += 0;
547
                    $qAnswers = $question->getAnswers();
548
                    foreach ($qAnswers as $qAnswer) {
549
                        if (trim(strip_tags($a)) == trim(strip_tags($qAnswer->getAnswer()))) {
550
                            $quizReplyAnswer->setPoints($qAnswer->getPoints());
551
                            $quizPoints += $qAnswer->getPoints();
552
                            $quizReplyAnswer->setCorrect($qAnswer->getCorrect());
553
                            $quizCorrectAnswers += $qAnswer->getCorrect();
554
                            break;
555
                        }
556
                    }
557
558
                    if (isset($group[$q.'-'.$a.'-data'])) {
559
                        $quizReplyAnswer->setAnswerData($group[$q.'-'.$a.'-data']);
560
                    }
561
                }
562
            }
563
        }
564
565
        $winner = $this->isWinner($game, $quizCorrectAnswers);
566
567
        $entry->setWinner($winner);
0 ignored issues
show
Bug introduced by
The method setWinner cannot be called on $entry (of type boolean).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
568
        // Every winning participation is eligible to draw
569
        // Make this modifiable in the admin (choose who can participate to draw)
570
        $entry->setDrawable($winner);
0 ignored issues
show
Bug introduced by
The method setDrawable cannot be called on $entry (of type boolean).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
571
        $entry->setPoints($quizPoints);
0 ignored issues
show
Bug introduced by
The method setPoints cannot be called on $entry (of type boolean).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
572
        $entry->setActive(false);
0 ignored issues
show
Bug introduced by
The method setActive cannot be called on $entry (of type boolean).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
573
        $entry = $entryMapper->update($entry);
574
575
        $quizReply->setEntry($entry);
576
        $quizReply->setTotalCorrectAnswers($quizCorrectAnswers);
577
        $quizReply->setMaxCorrectAnswers($maxCorrectAnswers);
578
        $quizReply->setTotalQuestions($totalQuestions);
579
580
        $quizReplyMapper->insert($quizReply);
581
582
        $this->getEventManager()->trigger(
583
            __FUNCTION__.'.post',
584
            $this,
585
            array('user' => $user, 'entry' => $entry, 'reply' => $quizReply, 'game' => $game)
586
        );
587
588
        return $entry;
589
    }
590
591
    public function isWinner($game, $quizCorrectAnswers = 0)
592
    {
593
        // Pour déterminer le gagnant, je regarde le nombre max de reponses correctes possibles
594
        // dans le jeu, puis je calcule le ratio de bonnes réponses et le compare aux conditions
595
        // de victoire
596
        $winner = false;
597
        $maxCorrectAnswers = $game->getMaxCorrectAnswers();
598
        if ($maxCorrectAnswers > 0) {
599
            $ratioCorrectAnswers = ($quizCorrectAnswers / $maxCorrectAnswers) * 100;
600
        } elseif ($game->getVictoryConditions() > 0) {
601
            // In the case I have a pronostic game for example
602
            $ratioCorrectAnswers = 0;
603
        } else {
604
            // In the case I want everybody to win
605
            $ratioCorrectAnswers = 100;
606
        }
607
608
        if ($game->getVictoryConditions() >= 0) {
609
            if ($ratioCorrectAnswers >= $game->getVictoryConditions()) {
610
                $winner = true;
611
            }
612
        }
613
        return $winner;
614
    }
615
616
    public function getEntriesHeader($game)
617
    {
618
        $header = parent::getEntriesHeader($game);
619
        $header['totalCorrectAnswers'] = 1;
620
621
        return $header;
622
    }
623
624 View Code Duplication
    public function getEntriesQuery($game)
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...
625
    {
626
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');
627
628
        $qb = $em->createQueryBuilder();
629
        $qb->select('
630
            r.id,
631
            u.username,
632
            u.title,
633
            u.firstname,
634
            u.lastname,
635
            u.email,
636
            u.optin,
637
            u.optinPartner,
638
            u.address,
639
            u.address2,
640
            u.postalCode,
641
            u.city,
642
            u.telephone,
643
            u.mobile,
644
            u.created_at,
645
            u.dob,
646
            e.winner,
647
            e.socialShares,
648
            e.playerData,
649
            e.updated_at,
650
            r.totalCorrectAnswers
651
            ')
652
            ->from('PlaygroundGame\Entity\QuizReply', 'r')
653
            ->innerJoin('r.entry', 'e')
654
            ->leftJoin('e.user', 'u')
655
            ->where($qb->expr()->eq('e.game', ':game'));
656
        
657
        $qb->setParameter('game', $game);
658
659
        return $qb->getQuery();
660
    }
661
662
    public function getGameEntity()
663
    {
664
        return new \PlaygroundGame\Entity\Quiz;
665
    }
666
667
    /**
668
     * getQuizMapper
669
     *
670
     * @return QuizMapperInterface
671
     */
672
    public function getQuizMapper()
673
    {
674
        if (null === $this->quizMapper) {
675
            $this->quizMapper = $this->getServiceManager()->get('playgroundgame_quiz_mapper');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getServiceManager...roundgame_quiz_mapper') can also be of type array. However, the property $quizMapper is declared as type object<PlaygroundGame\Se...ce\QuizMapperInterface>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
676
        }
677
678
        return $this->quizMapper;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->quizMapper; of type object|array adds the type array to the return on line 678 which is incompatible with the return type documented by PlaygroundGame\Service\Quiz::getQuizMapper of type PlaygroundGame\Service\QuizMapperInterface.
Loading history...
679
    }
680
681
    /**
682
     * setQuizMapper
683
     *
684
     * @param  QuizMapperInterface $quizMapper
685
     * @return Game
686
     */
687
    public function setQuizMapper(GameMapperInterface $quizMapper)
688
    {
689
        $this->quizMapper = $quizMapper;
0 ignored issues
show
Documentation Bug introduced by
It seems like $quizMapper of type object<PlaygroundGame\Mapper\GameInterface> is incompatible with the declared type object<PlaygroundGame\Se...ce\QuizMapperInterface> of property $quizMapper.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
690
691
        return $this;
692
    }
693
694
    /**
695
     * getQuizQuestionMapper
696
     *
697
     * @return QuizQuestionMapperInterface
698
     */
699
    public function getQuizQuestionMapper()
700
    {
701
        if (null === $this->quizQuestionMapper) {
702
            $this->quizQuestionMapper = $this->getServiceManager()->get('playgroundgame_quizquestion_mapper');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getServiceManager...e_quizquestion_mapper') can also be of type array. However, the property $quizQuestionMapper is declared as type object<PlaygroundGame\Se...uestionMapperInterface>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
703
        }
704
705
        return $this->quizQuestionMapper;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->quizQuestionMapper; of type object|array adds the type array to the return on line 705 which is incompatible with the return type documented by PlaygroundGame\Service\Quiz::getQuizQuestionMapper of type PlaygroundGame\Service\QuizQuestionMapperInterface.
Loading history...
706
    }
707
708
    /**
709
     * setQuizQuestionMapper
710
     *
711
     * @param  QuizQuestionMapperInterface $quizquestionMapper
712
     * @return Quiz
713
     */
714
    public function setQuizQuestionMapper($quizquestionMapper)
715
    {
716
        $this->quizQuestionMapper = $quizquestionMapper;
717
718
        return $this;
719
    }
720
721
    /**
722
     * setQuizAnswerMapper
723
     *
724
     * @param  QuizAnswerMapperInterface $quizAnswerMapper
725
     * @return Quiz
726
     */
727
    public function setQuizAnswerMapper($quizAnswerMapper)
728
    {
729
        $this->quizAnswerMapper = $quizAnswerMapper;
730
731
        return $this;
732
    }
733
734
    /**
735
     * getQuizAnswerMapper
736
     *
737
     * @return QuizAnswerMapperInterface
738
     */
739
    public function getQuizAnswerMapper()
740
    {
741
        if (null === $this->quizAnswerMapper) {
742
            $this->quizAnswerMapper = $this->getServiceManager()->get('playgroundgame_quizanswer_mapper');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getServiceManager...ame_quizanswer_mapper') can also be of type array. However, the property $quizAnswerMapper is declared as type object<PlaygroundGame\Se...zAnswerMapperInterface>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
743
        }
744
745
        return $this->quizAnswerMapper;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->quizAnswerMapper; of type object|array adds the type array to the return on line 745 which is incompatible with the return type documented by PlaygroundGame\Service\Quiz::getQuizAnswerMapper of type PlaygroundGame\Service\QuizAnswerMapperInterface.
Loading history...
746
    }
747
748
    /**
749
     * getQuizReplyMapper
750
     *
751
     * @return QuizReplyMapperInterface
752
     */
753
    public function getQuizReplyMapper()
754
    {
755
        if (null === $this->quizReplyMapper) {
756
            $this->quizReplyMapper = $this->getServiceManager()->get('playgroundgame_quizreply_mapper');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getServiceManager...game_quizreply_mapper') can also be of type array. However, the property $quizReplyMapper is declared as type object<PlaygroundGame\Se...izReplyMapperInterface>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
757
        }
758
759
        return $this->quizReplyMapper;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->quizReplyMapper; of type object|array adds the type array to the return on line 759 which is incompatible with the return type documented by PlaygroundGame\Service\Quiz::getQuizReplyMapper of type PlaygroundGame\Service\QuizReplyMapperInterface.
Loading history...
760
    }
761
762
    /**
763
     * setQuizReplyMapper
764
     *
765
     * @param  QuizReplyMapperInterface $quizreplyMapper
766
     * @return Quiz
767
     */
768
    public function setQuizReplyMapper($quizreplyMapper)
769
    {
770
        $this->quizReplyMapper = $quizreplyMapper;
771
772
        return $this;
773
    }
774
775
    /**
776
     * getQuizReplyAnswerMapper
777
     *
778
     * @return QuizReplyAnswerMapper
779
     */
780
    public function getQuizReplyAnswerMapper()
781
    {
782
        if (null === $this->quizReplyAnswerMapper) {
783
            $this->quizReplyAnswerMapper = $this->getServiceManager()->get('playgroundgame_quizreplyanswer_mapper');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getServiceManager...uizreplyanswer_mapper') can also be of type array. However, the property $quizReplyAnswerMapper is declared as type object<PlaygroundGame\Se...\QuizReplyAnswerMapper>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
784
        }
785
786
        return $this->quizReplyAnswerMapper;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->quizReplyAnswerMapper; of type object|array adds the type array to the return on line 786 which is incompatible with the return type documented by PlaygroundGame\Service\Q...etQuizReplyAnswerMapper of type PlaygroundGame\Service\QuizReplyAnswerMapper.
Loading history...
787
    }
788
789
     /**
790
     * setQuizReplyAnswerMapper
791
     *
792
     * @param  QuizReplyAnswerMapper $quizReplyAnswerMapper
793
     * @return Quiz
794
     */
795
    public function setQuizReplyAnswerMapper($quizReplyAnswerMapper)
796
    {
797
        $this->quizReplyAnswerMapper = $quizReplyAnswerMapper;
798
799
        return $this;
800
    }
801
}
802