Passed
Branch dev3 (6039a0)
by Dispositif
02:46
created

OuvrageFormatHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 1
b 0
f 0
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 23 3
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
11
namespace App\Domain\WikiOptimizer\Handlers;
12
13
class OuvrageFormatHandler extends AbstractOuvrageHandler
14
{
15
    public function handle()
16
    {
17
        if (($value = $this->getParam('format'))) {
18
            // predict if 'format électronique'
19
            // format electronique lié au champ 'lire en ligne'
20
            // 2015 https://fr.wikipedia.org/wiki/Discussion_mod%C3%A8le:Ouvrage#format,_format_livre,_format_%C3%A9lectronique
21
            //            if (preg_match('#(pdf|epub|html|kindle|audio|\{\{aud|jpg)#i', $value) > 0) {
22
            //
23
            //                $this->setParam('format électronique', $value);
24
            //                $this->unsetParam('format');
25
            //                $this->log('format:électronique?');
26
            //
27
            //                return;
28
            //            }
29
            if (preg_match(
30
                    '#(ill\.|couv\.|in-\d|in-fol|poche|broché|relié|{{unité|{{Dunité|\d{2} ?cm|\|cm}}|vol\.|A4)#i',
31
                    $value
32
                ) > 0
33
            ) {
34
                $this->setParam('format livre', $value);
35
                $this->unsetParam('format');
36
                $this->addSummaryLog('format:livre?');
37
                $this->optiStatus->setNotCosmetic(true);
38
            }
39
            // Certainement 'format électronique'...
40
        }
41
    }
42
}