IncorrectQuestion::insertIncorrect()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
ccs 0
cts 10
cp 0
rs 9.4285
cc 1
eloc 8
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: device
5
 * Date: 26.02.16
6
 * Time: 14:53
7
 */
8
9
namespace AppBundle\Services;
10
11
12
use AppBundle\Entity\Answer;
13
use AppBundle\Entity\Question;
14
use Symfony\Bridge\Doctrine\RegistryInterface;
15
16
class IncorrectQuestion
17
{
18
    private $doctrine;
19
20
    public function __construct(RegistryInterface $doctrine)
21
    {
22
        $this->doctrine = $doctrine;
23
    }
24
25
    public function insertIncorrect(Question $question)
26
    {
27
        $em = $this->doctrine->getManager();
28
29
        $answer = new Answer();
30
        $answer->setQuestion($question);
31
        $answer->setCorrectly(true);
32
        $answer->setTextAnswer('There is no correct answer');
33
34
        $em->persist($answer);
35
36
        return;
37
    }
38
}