Passed
Pull Request — master (#5072)
by Yannick
18:09 queued 11:34
created

Version20230321164019   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 3 1
A up() 0 24 2
A down() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
8
9
use Chamilo\CoreBundle\Entity\TrackEAttemptQualify;
10
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
11
use Doctrine\DBAL\Schema\Schema;
12
13
class Version20230321164019 extends AbstractMigrationChamilo
14
{
15
    public function getDescription(): string
16
    {
17
        return 'Migrate track_e_attempt_recording';
18
    }
19
20
    public function up(Schema $schema): void
21
    {
22
        $container = $this->getContainer();
23
        $doctrine = $container->get('doctrine');
24
        $em = $doctrine->getManager();
25
26
        $sql = 'SELECT * FROM track_e_attempt_recording';
27
        $connection = $this->getEntityManager()->getConnection();
28
        $result = $connection->executeQuery($sql);
29
        $items = $result->fetchAllAssociative();
30
31
        foreach ($items as $item) {
32
            $trackQualify = new TrackEAttemptQualify();
33
            $trackQualify
34
                ->setExeId($item['exe_id'])
0 ignored issues
show
Bug introduced by
The method setExeId() does not exist on Chamilo\CoreBundle\Entity\TrackEAttemptQualify. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
                ->/** @scrutinizer ignore-call */ 
35
                  setExeId($item['exe_id'])

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
                ->setQuestionId($item['question_id'])
36
                ->setAnswer($item['answer'])
37
                ->setMarks((int) $item['marks'])
38
                ->setAuthor($item['author'])
39
                ->setTeacherComment($item['teacher_comment'])
40
                ->setSessionId($item['session_id'])
41
            ;
42
            $em->persist($trackQualify);
43
            $em->flush();
44
        }
45
    }
46
47
    public function down(Schema $schema): void
48
    {
49
    }
50
}
51