Completed
Push — develop ( b776d6...f46b16 )
by greg
03:10
created

Quiz::getEntriesQuery()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 10

Duplication

Lines 36
Ratio 97.3 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 36
loc 37
rs 8.8571
cc 1
eloc 10
nc 1
nop 1
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
    /**
184
     * This function update the sort order of the questions in a Quiz
185
     *
186
     * @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...
187
     * @return boolean
188
     */
189
    public function updatePrediction($question)
190
    {
191
        // je recherche toutes les participations au jeu
192
        $entries = $this->getEntryMapper()->findByGameId($question->getQuiz());
193
194
        $answers = $question->getAnswers();
195
196
        $answersarray = array();
197
        foreach ($answers as $answer) {
198
            $answersarray[$answer->getId()] = $answer;
199
        }
200
201
        // I update all answers with points and correctness
202
        // Refactorer findByEntryAndQuestion pour qu'elle fonctionne avec QuizReplyAnswer
203
        /**
204
         * 1. Je recherche $this->getQuizReplyMapper()->findByEntry($entry)
205
         * 2. Pour chaque entrée trouvée, je recherche
206
         * $this->getQuizReplyAnswerMapper()->findByReplyAndQuestion($reply, $question->getId())
207
         * 3. Je mets à jour reply avec le nb de bonnes réponses
208
         * 4. Je trigger une story ?
209
         */
210
        foreach ($entries as $entry) {
211
            $quizReplies = $this->getQuizReplyMapper()->findByEntry($entry);
212
            if ($quizReplies) {
213
                foreach ($quizReplies as $reply) {
214
                    $quizReplyAnswers = $this->getQuizReplyAnswerMapper()->findByReplyAndQuestion(
215
                        $reply,
216
                        $question->getId()
217
                    );
218
                    $quizPoints = 0;
219
                    $quizCorrectAnswers = 0;
220
                    if ($quizReplyAnswers) {
221
                        foreach ($quizReplyAnswers as $quizReplyAnswer) {
222
                            if (2 != $question->getType()) {
223
                                if ($answersarray[$quizReplyAnswer->getAnswerId()]) {
224
                                    $updatedAnswer = $answersarray[$quizReplyAnswer->getAnswerId()];
225
                                    $quizReplyAnswer->setPoints($updatedAnswer->getPoints());
226
                                    $quizReplyAnswer->setCorrect($updatedAnswer->getCorrect());
227
                                    $quizReplyAnswer = $this->getQuizReplyAnswerMapper()->update(
228
                                        $quizReplyAnswer
229
                                    );
230
                                }
231
                            } else {
232
                                // question is a textarea
233
                                // search for a matching answer
234
                                foreach ($answers as $answer) {
235
                                    if (trim(strip_tags($answer->getAnswer())) == trim(
236
                                        strip_tags($quizReplyAnswer->getAnswer())
237
                                    )
238
                                    ) {
239
                                        $quizReplyAnswer->setPoints($answer->getPoints());
240
                                        $quizReplyAnswer->setCorrect($answer->getCorrect());
241
                                        $quizReplyAnswer = $this->getQuizReplyAnswerMapper()->update(
242
                                            $quizReplyAnswer
243
                                        );
244
                                        break;
245
                                    } else {
246
                                        $quizReplyAnswer->setPoints(0);
247
                                        $quizReplyAnswer->setCorrect(false);
248
                                        $quizReplyAnswer = $this->getQuizReplyAnswerMapper()->update(
249
                                            $quizReplyAnswer
250
                                        );
251
                                    }
252
                                }
253
                            }
254
                        }
255
                    }
256
257
                    // The reply has been updated with correct answers and points for this question.
258
                    // I count the whole set of points for this reply and update the entry
259
                    foreach ($reply->getAnswers() as $a) {
260
                        if ($a->getCorrect()) {
261
                            $quizPoints += $a->getPoints();
262
                            $quizCorrectAnswers += $a->getCorrect();
263
                        }
264
                    }
265
                }
266
            }
267
            $winner = $this->isWinner($question->getQuiz(), $quizCorrectAnswers);
0 ignored issues
show
Bug introduced by
The variable $quizCorrectAnswers does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
268
            $entry->setWinner($winner);
269
            $entry->setPoints($quizPoints);
0 ignored issues
show
Bug introduced by
The variable $quizPoints does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
270
            // The entry should be inactive : entry->setActive(false);
271
            $entry = $this->getEntryMapper()->update($entry);
272
        }
273
274
        $this->getEventManager()->trigger(
275
            __FUNCTION__.'.post',
276
            $this,
277
            array('question' => $question)
278
        );
279
    }
280
281
    /**
282
     * This function update the sort order of the questions in a Quiz
283
     *
284
     * @param  string $data
285
     * @return boolean
286
     */
287
    public function sortQuestion($data)
288
    {
289
        $arr = explode(",", $data);
290
291
        foreach ($arr as $k => $v) {
292
            $question = $this->getQuizQuestionMapper()->findById($v);
293
            $question->setPosition($k);
294
            $this->getQuizQuestionMapper()->update($question);
295
        }
296
297
        return true;
298
    }
299
300
    /**
301
     * @return string
302
     */
303
    public function calculateMaxAnswersQuestion($question)
304
    {
305
        $question_max_points = 0;
306
        $question_max_correct_answers = 0;
307
        // Closed question : Only one answer allowed
308
        if ($question->getType() == 0) {
309
            foreach ($question->getAnswers() as $answer) {
310
                if ($answer->getPoints() > $question_max_points) {
311
                    $question_max_points = $answer->getPoints();
312
                }
313
                if ($answer->getCorrect() && $question_max_correct_answers==0) {
314
                    $question_max_correct_answers=1;
315
                }
316
            }
317
            if ($question_max_correct_answers == 0) {
318
                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...
319
            }
320
        // Closed question : Many answers allowed
321
        } elseif ($question->getType() == 1) {
322
            foreach ($question->getAnswers() as $answer) {
323
                $question_max_points += $answer->getPoints();
324
325
                if ($answer->getCorrect()) {
326
                    ++$question_max_correct_answers;
327
                }
328
            }
329
            if ($question_max_correct_answers == 0) {
330
                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...
331
            }
332
        // Not a question : A textarea to fill in
333
        } elseif ($question->getType() == 2) {
334
            $question_max_correct_answers = 0;
335
        }
336
337
        $question->setMaxPoints($question_max_points);
338
        $question->setMaxCorrectAnswers($question_max_correct_answers);
339
340
        return $question;
341
    }
342
343
    public function calculateMaxAnswersQuiz($quiz)
344
    {
345
        $question_max_points = 0;
346
        $question_max_correct_answers = 0;
347
        foreach ($quiz->getQuestions() as $question) {
348
            $question_max_points += $question->getMaxPoints();
349
            $question_max_correct_answers += $question->getMaxCorrectAnswers();
350
        }
351
        $quiz->setMaxPoints($question_max_points);
352
        $quiz->setMaxCorrectAnswers($question_max_correct_answers);
353
354
        return $quiz;
355
    }
356
357 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...
358
    {
359
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');
360
361
        $query = $em->createQuery(
362
            "SELECT COUNT(e.id) FROM PlaygroundGame\Entity\Entry e, PlaygroundGame\Entity\Game g
363
                WHERE e.user = :user
364
                AND g.classType = 'quiz'
365
                AND e.points > 0"
366
        );
367
        $query->setParameter('user', $user);
368
        $number = $query->getSingleScalarResult();
369
370
        return $number;
371
    }
372
373
    public function createQuizReply($data, $game, $user)
374
    {
375
        // Si mon nb de participation est < au nb autorisé, j'ajoute une entry + reponses au quiz et points
376
        $quizReplyMapper = $this->getQuizReplyMapper();
377
        $entryMapper = $this->getEntryMapper();
378
        $entry = $this->findLastActiveEntry($game, $user);
379
380
        if (!$entry) {
381
            return false;
382
        }
383
384
        $quizPoints          = 0;
385
        $quizCorrectAnswers  = 0;
386
        $maxCorrectAnswers = $game->getMaxCorrectAnswers();
387
        $totalQuestions = 0;
388
389
        $quizReply = $this->getQuizReplyMapper()->getLastGameReply($entry);
390
        if (!$quizReply) {
391
            $quizReply = new QuizReply();
392
        } else {
393
            foreach ($quizReply->getAnswers() as $answer) {
394
                $this->getQuizReplyAnswerMapper()->remove($answer);
395
            }
396
        }
397
        
398
        foreach ($data as $group) {
399
            foreach ($group as $q => $a) {
400
                if (strlen($q) > 5 && strpos($q, '-data', strlen($q) - 5) !== false) {
401
                    continue; // answer data is processed below
402
                }
403
                $question = $this->getQuizQuestionMapper()->findById((int) str_replace('q', '', $q));
404
                ++$totalQuestions;
405
                if (is_array($a)) {
406
                    foreach ($a as $k => $answer_id) {
407
                        $answer = $this->getQuizAnswerMapper()->findById($answer_id);
408 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...
409
                            $quizReplyAnswer = new QuizReplyAnswer();
410
                            $quizReplyAnswer->setAnswer($answer->getAnswer());
411
                            $quizReplyAnswer->setAnswerId($answer_id);
412
                            $quizReplyAnswer->setQuestion($question->getQuestion());
413
                            $quizReplyAnswer->setQuestionId($question->getId());
414
                            $quizReplyAnswer->setPoints($answer->getPoints());
415
                            $quizReplyAnswer->setCorrect($answer->getCorrect());
416
417
                            $quizReply->addAnswer($quizReplyAnswer);
418
                            $quizPoints += $answer->getPoints();
419
                            $quizCorrectAnswers += $answer->getCorrect();
420
421
                            if (isset($group[$q.'-'.$answer_id.'-data'])) {
422
                                $quizReplyAnswer->setAnswerData($group[$q.'-'.$answer_id.'-data']);
423
                            }
424
                        }
425
                    }
426
                } elseif ($question->getType() == 0 || $question->getType() == 1) {
427
                    ++$totalQuestions;
428
                    $answer = $this->getQuizAnswerMapper()->findById($a);
429 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...
430
                        $quizReplyAnswer = new QuizReplyAnswer();
431
                        $quizReplyAnswer->setAnswer($answer->getAnswer());
432
                        $quizReplyAnswer->setAnswerId($a);
433
                        $quizReplyAnswer->setQuestion($question->getQuestion());
434
                        $quizReplyAnswer->setQuestionId($question->getId());
435
                        $quizReplyAnswer->setPoints($answer->getPoints());
436
                        $quizReplyAnswer->setCorrect($answer->getCorrect());
437
438
                        $quizReply->addAnswer($quizReplyAnswer);
439
                        $quizPoints += $answer->getPoints();
440
                        $quizCorrectAnswers += $answer->getCorrect();
441
                        if (isset($group[$q.'-'.$a.'-data'])) {
442
                            $quizReplyAnswer->setAnswerData($group[$q.'-'.$a.'-data']);
443
                        }
444
                    }
445
                } elseif ($question->getType() == 2) {
446
                    ++$totalQuestions;
447
                    $quizReplyAnswer = new QuizReplyAnswer();
448
                    
449
                    $quizReplyAnswer->setAnswer($a);
450
                    $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...
451
                    $quizReplyAnswer->setQuestion($question->getQuestion());
452
                    $quizReplyAnswer->setQuestionId($question->getId());
453
                    $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...
454
                    $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...
455
456
                    $quizReply->addAnswer($quizReplyAnswer);
457
                    $quizPoints += 0;
458
                    $quizCorrectAnswers += 0;
459
                    $qAnswers = $question->getAnswers();
460
                    foreach ($qAnswers as $qAnswer) {
461
                        if (trim(strip_tags($a)) == trim(strip_tags($qAnswer->getAnswer()))) {
462
                            $quizReplyAnswer->setPoints($qAnswer->getPoints());
463
                            $quizPoints += $qAnswer->getPoints();
464
                            $quizReplyAnswer->setCorrect($qAnswer->getCorrect());
465
                            $quizCorrectAnswers += $qAnswer->getCorrect();
466
                            break;
467
                        }
468
                    }
469
470
                    if (isset($group[$q.'-'.$a.'-data'])) {
471
                        $quizReplyAnswer->setAnswerData($group[$q.'-'.$a.'-data']);
472
                    }
473
                }
474
            }
475
        }
476
477
        $winner = $this->isWinner($game, $quizCorrectAnswers);
478
479
        $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...
480
        // Every winning participation is eligible to draw
481
        // Make this modifiable in the admin (choose who can participate to draw)
482
        $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...
483
        $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...
484
        $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...
485
        $entry = $entryMapper->update($entry);
486
487
        $quizReply->setEntry($entry);
488
        $quizReply->setTotalCorrectAnswers($quizCorrectAnswers);
489
        $quizReply->setMaxCorrectAnswers($maxCorrectAnswers);
490
        $quizReply->setTotalQuestions($totalQuestions);
491
492
        $quizReplyMapper->insert($quizReply);
493
494
        $this->getEventManager()->trigger(
495
            __FUNCTION__.'.post',
496
            $this,
497
            array('user' => $user, 'entry' => $entry, 'reply' => $quizReply, 'game' => $game)
498
        );
499
500
        return $entry;
501
    }
502
503
    public function isWinner($game, $quizCorrectAnswers = 0)
504
    {
505
        // Pour déterminer le gagnant, je regarde le nombre max de reponses correctes possibles
506
        // dans le jeu, puis je calcule le ratio de bonnes réponses et le compare aux conditions
507
        // de victoire
508
        $winner = false;
0 ignored issues
show
Unused Code introduced by
$winner 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...
509
        $maxCorrectAnswers = $game->getMaxCorrectAnswers();
510
        if ($maxCorrectAnswers > 0) {
511
            $ratioCorrectAnswers = ($quizCorrectAnswers / $maxCorrectAnswers) * 100;
512
        } elseif ($game->getVictoryConditions() > 0) {
513
            // In the case I have a pronostic game for example
514
            $ratioCorrectAnswers = 0;
515
        } else {
516
            // In the case I want everybody to win
517
            $ratioCorrectAnswers = 100;
518
        }
519
520
        $winner = false;
521
        if ($game->getVictoryConditions() >= 0) {
522
            if ($ratioCorrectAnswers >= $game->getVictoryConditions()) {
523
                $winner = true;
524
            }
525
        }
526
        return $winner;
527
    }
528
529
    public function getEntriesHeader($game)
530
    {
531
        $header = parent::getEntriesHeader($game);
532
        $header['totalCorrectAnswers'] = 1;
533
534
        return $header;
535
    }
536
537 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...
538
    {
539
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');
540
541
        $qb = $em->createQueryBuilder();
542
        $qb->select('
543
            r.id,
544
            u.username,
545
            u.title,
546
            u.firstname,
547
            u.lastname,
548
            u.email,
549
            u.optin,
550
            u.optinPartner,
551
            u.address,
552
            u.address2,
553
            u.postalCode,
554
            u.city,
555
            u.telephone,
556
            u.mobile,
557
            u.created_at,
558
            u.dob,
559
            e.winner,
560
            e.socialShares,
561
            e.playerData,
562
            e.updated_at,
563
            r.totalCorrectAnswers
564
            ')
565
            ->from('PlaygroundGame\Entity\QuizReply', 'r')
566
            ->innerJoin('r.entry', 'e')
567
            ->leftJoin('e.user', 'u')
568
            ->where($qb->expr()->eq('e.game', ':game'));
569
        
570
        $qb->setParameter('game', $game);
571
572
        return $qb->getQuery();
573
    }
574
575
    public function getGameEntity()
576
    {
577
        return new \PlaygroundGame\Entity\Quiz;
578
    }
579
580
    /**
581
     * getQuizMapper
582
     *
583
     * @return QuizMapperInterface
584
     */
585
    public function getQuizMapper()
586
    {
587
        if (null === $this->quizMapper) {
588
            $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...
589
        }
590
591
        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 591 which is incompatible with the return type documented by PlaygroundGame\Service\Quiz::getQuizMapper of type PlaygroundGame\Service\QuizMapperInterface.
Loading history...
592
    }
593
594
    /**
595
     * setQuizMapper
596
     *
597
     * @param  QuizMapperInterface $quizMapper
598
     * @return Game
599
     */
600
    public function setQuizMapper(GameMapperInterface $quizMapper)
601
    {
602
        $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...
603
604
        return $this;
605
    }
606
607
    /**
608
     * getQuizQuestionMapper
609
     *
610
     * @return QuizQuestionMapperInterface
611
     */
612
    public function getQuizQuestionMapper()
613
    {
614
        if (null === $this->quizQuestionMapper) {
615
            $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...
616
        }
617
618
        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 618 which is incompatible with the return type documented by PlaygroundGame\Service\Quiz::getQuizQuestionMapper of type PlaygroundGame\Service\QuizQuestionMapperInterface.
Loading history...
619
    }
620
621
    /**
622
     * setQuizQuestionMapper
623
     *
624
     * @param  QuizQuestionMapperInterface $quizquestionMapper
625
     * @return Quiz
626
     */
627
    public function setQuizQuestionMapper($quizquestionMapper)
628
    {
629
        $this->quizQuestionMapper = $quizquestionMapper;
630
631
        return $this;
632
    }
633
634
    /**
635
     * setQuizAnswerMapper
636
     *
637
     * @param  QuizAnswerMapperInterface $quizAnswerMapper
638
     * @return Quiz
639
     */
640
    public function setQuizAnswerMapper($quizAnswerMapper)
641
    {
642
        $this->quizAnswerMapper = $quizAnswerMapper;
643
644
        return $this;
645
    }
646
647
    /**
648
     * getQuizAnswerMapper
649
     *
650
     * @return QuizAnswerMapperInterface
651
     */
652
    public function getQuizAnswerMapper()
653
    {
654
        if (null === $this->quizAnswerMapper) {
655
            $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...
656
        }
657
658
        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 658 which is incompatible with the return type documented by PlaygroundGame\Service\Quiz::getQuizAnswerMapper of type PlaygroundGame\Service\QuizAnswerMapperInterface.
Loading history...
659
    }
660
661
    /**
662
     * getQuizReplyMapper
663
     *
664
     * @return QuizReplyMapperInterface
665
     */
666
    public function getQuizReplyMapper()
667
    {
668
        if (null === $this->quizReplyMapper) {
669
            $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...
670
        }
671
672
        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 672 which is incompatible with the return type documented by PlaygroundGame\Service\Quiz::getQuizReplyMapper of type PlaygroundGame\Service\QuizReplyMapperInterface.
Loading history...
673
    }
674
675
    /**
676
     * setQuizReplyMapper
677
     *
678
     * @param  QuizReplyMapperInterface $quizreplyMapper
679
     * @return Quiz
680
     */
681
    public function setQuizReplyMapper($quizreplyMapper)
682
    {
683
        $this->quizReplyMapper = $quizreplyMapper;
684
685
        return $this;
686
    }
687
688
    /**
689
     * getQuizReplyAnswerMapper
690
     *
691
     * @return QuizReplyAnswerMapper
692
     */
693
    public function getQuizReplyAnswerMapper()
694
    {
695
        if (null === $this->quizReplyAnswerMapper) {
696
            $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...
697
        }
698
699
        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 699 which is incompatible with the return type documented by PlaygroundGame\Service\Q...etQuizReplyAnswerMapper of type PlaygroundGame\Service\QuizReplyAnswerMapper.
Loading history...
700
    }
701
702
     /**
703
     * setQuizReplyAnswerMapper
704
     *
705
     * @param  QuizReplyAnswerMapper $quizReplyAnswerMapper
706
     * @return Quiz
707
     */
708
    public function setQuizReplyAnswerMapper($quizReplyAnswerMapper)
709
    {
710
        $this->quizReplyAnswerMapper = $quizReplyAnswerMapper;
711
712
        return $this;
713
    }
714
}
715