Passed
Push — dev ( b7aeac...61ab03 )
by Dispositif
03:20
created

JsonLDMapper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 20
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 16 1
1
<?php
2
/**
3
 * This file is part of dispositif/wikibot application (@github)
4
 * 2019/2020 © 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
class JsonLDMapper implements MapperInterface
15
{
16
    use ExternConverterTrait;
17
18
    public function process($jsonLD): array
19
    {
20
        return [
21
            'DATA-TYPE' => 'JSON-LD',
22
            'DATA-ARTICLE' => $jsonLD['@type'] === 'NewsArticle',
23
24
            'périodique' => $this->clean($jsonLD['publisher']['name'] ?? null),
25
            'titre' => $this->clean($jsonLD['headline']), // obligatoire
26
            'url' => $jsonLD['url'] ?? $jsonLD['mainEntityOfPage']['@id'] ?? null,
27
            'date' => $this->convertDate($jsonLD['datePublished'] ?? $jsonLD['dateCreated'] ?? null), //
28
            // 2020-03-19T19:13:01.000Z
29
            'auteur1' => $this->wikifyPressAgency($this->convertAuteur($jsonLD, 0)),
30
            'auteur2' => $this->convertAuteur($jsonLD, 1),
31
            'auteur3' => $this->convertAuteur($jsonLD, 2),
32
            'auteur institutionnel' => $this->convertInstitutionnel($jsonLD),
33
            'url-access' => $this->convertURLaccess($jsonLD),
34
        ];
35
    }
36
}
37