Failed Conditions
Push — master ( 27554e...857869 )
by Luca
09:08
created

Version20221117163523::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 18
ccs 0
cts 12
cp 0
rs 9.8666
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Migration;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\Migrations\AbstractMigration;
9
10
class Version20221117163523 extends AbstractMigration
11
{
12
    public function up(Schema $schema): void
13
    {
14
        // Some cards have empty plain_name, even tough they never should, so we re-affect them here
15
        $this->addSql("UPDATE card SET plain_name = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(name, '<strong>', ''), '</strong>', ''), '<em>', ''), '</em>', ''), '<u>', ''), '</u>', '') WHERE plain_name = ''");
16
17
        // Convert unbreakable spaces into normal spaces
18
        $unbreakable = html_entity_decode('&nbsp;');
19
        $this->addSql(
20
            <<<STRING
21
                UPDATE `card` SET
22
                    name = REPLACE(REPLACE(name, '&nbsp;', ' '), '$unbreakable', ' '),
23
                    expanded_name = REPLACE(REPLACE(expanded_name, '&nbsp;', ' '), '$unbreakable', ' '),
24
                    literature = REPLACE(REPLACE(literature, '&nbsp;', ' '), '$unbreakable', ' '),
25
                    corpus = REPLACE(REPLACE(corpus, '&nbsp;', ' '), '$unbreakable', ' '),
26
                    url_description = REPLACE(REPLACE(url_description, '&nbsp;', ' '), '$unbreakable', ' '),
27
                    plain_name = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(plain_name,
28
                        '&nbsp;', ' '),
29
                       '$unbreakable', ' '),
30
                       '&amp;', '&'),
31
                       '&gt;', '>'),
32
                       '&lt;', '<'),
33
                       '&quot;', '"')
34
                STRING
35
        );
36
    }
37
}
38