Passed
Branch master (ee24dc)
by Dispositif
03:19 queued 39s
created

AuthorLinkHandler::handle()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 17
rs 9.8666
cc 4
nc 3
nop 0
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\WikiOptimizer\Handlers;
11
12
use App\Domain\Utils\WikiTextUtil;
13
14
class AuthorLinkHandler extends AbstractOuvrageHandler
15
{
16
    public function handle()
17
    {
18
        $auteurParams = ['auteur1', 'auteur2', 'auteur2', 'titre'];
19
        foreach ($auteurParams as $auteurParam) {
20
            if ($this->ouvrage->hasParamValue($auteurParam)
21
                && $this->ouvrage->hasParamValue('lien '.$auteurParam)
22
            ) {
23
                $this->ouvrage->setParam(
24
                    $auteurParam,
25
                    WikiTextUtil::wikilink(
26
                        $this->ouvrage->getParam($auteurParam),
0 ignored issues
show
Bug introduced by
It seems like $this->ouvrage->getParam($auteurParam) can also be of type null; however, parameter $label of App\Domain\Utils\WikiTextUtil::wikilink() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

26
                        /** @scrutinizer ignore-type */ $this->ouvrage->getParam($auteurParam),
Loading history...
27
                        $this->ouvrage->getParam('lien '.$auteurParam)
28
                    )
29
                );
30
                $this->ouvrage->unsetParam('lien '.$auteurParam);
31
                $this->optiStatus->addSummaryLog('±lien '.$auteurParam);
32
                $this->optiStatus->setNotCosmetic(true);
33
            }
34
        }
35
    }
36
}