Passed
Push — dev ( 043eb4...bf3609 )
by Dispositif
06:23
created

LiberationMapper::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 12
nc 2
nop 1
dl 0
loc 18
rs 9.8666
c 1
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
11
namespace App\Domain\Publisher;
12
13
14
use DateTime;
15
16
/**
17
 * Class LiberationMapper
18
 *
19
 * @package App\Domain\Publisher
20
 */
21
class LiberationMapper extends WebMapper
22
{
23
    public function process($data): array
24
    {
25
        if(!isset($data['JSON-LD'])) {
26
            return [];
27
        }
28
        $data = $data['JSON-LD'];
29
30
        return [
31
            //            'langue' => 'fr',
32
            'périodique' => '[[Libération (journal)|Libération]]',
33
            //           'acces' =>  $data['isAccessibleForFree'],
34
            'titre' => html_entity_decode($data['headline'] ?? null),
35
            'lire en ligne' => $data['mainEntityOfPage']['@id'],
36
            'date' => $this->convertDate($data['dateCreated']), //  "2017-11-17T20:06:13"
37
            'auteur1' => $this->convertAuteur($data, 0),
38
            'auteur2' => $this->convertAuteur($data, 1),
39
            'auteur3' => $this->convertAuteur($data, 2),
40
            'auteur institutionnel' => $this->convertInstitutionnel($data),
41
        ];
42
    }
43
44
}
45