Passed
Branch master (fd6b1a)
by Dispositif
03:51 queued 01:13
created

MixAutoParams   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 35
c 1
b 0
f 0
dl 0
loc 49
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 0 22 8
1
<?php
2
/*
3
 * This file is part of dispositif/wikibot application (@github)
4
 * 2019-2023 © Philippe M./Irønie  <[email protected]>
5
 * For the full copyright and MIT license information, view the license file.
6
 */
7
8
declare(strict_types=1);
9
10
namespace App\Domain\Transformers\Handlers;
11
12
// completion automatique des paramètres manquants
13
class MixAutoParams extends AbstractMixHandler
14
{
15
    public const WIKI_LANGUAGE = 'fr';
16
17
    public const SKIP_PARAMS = [
18
            'isbn invalide',
19
            'auteurs',
20
            'auteur1',
21
            'prénom1',
22
            'nom1',
23
            'auteur2',
24
            'prénom2',
25
            'nom2',
26
            'auteur3',
27
            'prénom3',
28
            'nom3',
29
            'auteur4',
30
            'prénom4',
31
            'nom4',
32
            'lire en ligne',
33
            'présentation en ligne',
34
            'date',
35
            'sous-titre',
36
            'lien auteur1',
37
            'lien auteur2',
38
        ];
39
40
    public function handle()
41
    {
42
        foreach ($this->book->toArray() as $param => $value) {
43
            if (!$this->origin->hasParamValue($param)) {
44
                if (in_array($param, self::SKIP_PARAMS)) {
45
                    continue;
46
                }
47
                // skip 'année' if 'date' not empty
48
                if ('année' === $param && $this->origin->hasParamValue('date')) {
49
                    continue;
50
                }
51
52
                $this->origin->setParam($param, $value);
53
54
                if ('langue' === $param && self::WIKI_LANGUAGE === $value) {
55
                    //$this->log('fr'.$param);
56
                    continue;
57
                }
58
59
                $this->optiStatus->addSummaryLog('++' . $param);
60
                $this->optiStatus->setMajor(true);
61
                $this->optiStatus->setNotCosmetic(true);
62
            }
63
        }
64
    }
65
}