Passed
Branch master (61ab03)
by Dispositif
05:16 queued 02:29
created

JsonLDMapper::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 16
rs 9.8666
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