Passed
Push — dev ( 1a31b5...8e8e3b )
by Dispositif
03:08
created

OuvragesInPageOptimize::onlyOneLinkByPage()   B

Complexity

Conditions 7
Paths 11

Size

Total Lines 24
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 16
nc 11
nop 1
dl 0
loc 24
rs 8.8333
c 0
b 0
f 0
1
<?php
2
///**
3
// * This file is part of dispositif/wikibot application
4
// * 2019 : Philippe M. <[email protected]>
5
// * For the full copyright and MIT license information, please view the LICENSE file.
6
// */
7
//
8
//declare(strict_types=1);
9
//
10
//namespace App\Domain;
11
//
12
//use App\Domain\Models\Wiki\OuvrageTemplate;
13
//use App\Domain\Utils\WikiTextUtil;
14
//
15
//class OuvragesInPageOptimize
16
//{
17
//    /**
18
//     * @var OuvrageTemplate[]
19
//     */
20
//    private $ouvrages;
21
//
22
//    private $page;
23
//
24
//    /**
25
//     * @var array
26
//     */
27
//    private $log;
28
//
29
//    public function __construct(string $page, array $ouvrages)
30
//    {
31
//        $this->page = $page;
32
//        $this->ouvrages = $ouvrages;
33
//    }
34
//
35
//
36
////    /**
37
////     * Delete wikilink if already showed by precedent template.
38
////     *
39
////     * @param array $ouvrages
40
////     */
41
////    private function onlyOneLinkByPage(array $ouvrages)
42
////    {
43
////        $paramIsWikilink = ['lien auteur1', 'lien auteur2', 'lien auteur3', 'lien éditeur'];
44
////        /**
45
////         * @var OuvrageTemplate
46
////         */
47
////        $deja = [];
48
////        foreach ($ouvrages as $ouvrage) {
49
////            $dat = $ouvrage->toArray();
50
////            foreach ($dat as $param => $value) {
51
////                if (in_array($param, $paramIsWikilink)) {
52
////                    if (isset($deja[$value])) {
53
////                        $ouvrage->unsetParam($param);
54
////                        $this->log('-'.$param);
55
////                    }
56
////                    $deja[$value] = 1;
57
////                }
58
////                if (preg_match('#\[\[(.+)]]#', $value, $matches) > 0) {
59
////                    if (isset($deja[$matches[1]])) {
60
////                        $newvalue = WikiTextUtil::unWikify($value);
61
////                        $ouvrage->setParam($param, $newvalue);
62
////                        $this->log('unlink/article');
63
////                    }
64
////                    $deja[$matches[1]] = 1;
65
////                }
66
////            }
67
////        }
68
////    }
69
//
70
////    private function unWikifyByPage(OuvrageTemplate $ouvrage)
71
////    {
72
////        $params = ['lien auteur', 'lien auteur1', 'lien auteur2', 'lien éditeur'];
73
////        foreach ($params as $param) {
74
////            if ($ouvrage->getParam($param) === $this->page) {
75
////                $ouvrage->unsetParam($param);
76
////                //                $ouvrage->log('-'.$param);
77
////            }
78
////        }
79
////    }
80
//}
81