Passed
Branch dev (6bb8f6)
by Dispositif
03:01
created

ExternLDMapperTrait::mapArticleDataFromJSONLD()   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
nc 1
nop 1
dl 0
loc 16
rs 9.8666
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
11
namespace App\Domain\Publisher;
12
13
14
trait ExternLDMapperTrait
15
{
16
    protected function mapArticleDataFromJSONLD(array $jsonLD): array
17
    {
18
        return [
19
            'DATA-TYPE' => 'JSON-LD',
20
            'DATA-ARTICLE' => $jsonLD['@type'] === 'NewsArticle',
21
22
            'périodique' => $this->clean($jsonLD['publisher']['name'] ?? null),
0 ignored issues
show
Bug introduced by
It seems like clean() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
            'périodique' => $this->/** @scrutinizer ignore-call */ clean($jsonLD['publisher']['name'] ?? null),
Loading history...
23
            'titre' => $this->clean($jsonLD['headline']), // obligatoire
24
            'url' => $jsonLD['url'] ?? $jsonLD['mainEntityOfPage']['@id'] ?? null,
25
            'date' => $this->convertDate($jsonLD['datePublished'] ?? $jsonLD['dateCreated'] ?? null), //
26
            // 2020-03-19T19:13:01.000Z
27
            'auteur1' => $this->wikifyPressAgency($this->convertAuteur($jsonLD, 0)),
28
            'auteur2' => $this->convertAuteur($jsonLD, 1),
29
            'auteur3' => $this->convertAuteur($jsonLD, 2),
30
            'auteur institutionnel' => $this->convertInstitutionnel($jsonLD),
31
            'url-access' => $this->convertURLaccess($jsonLD),
32
        ];
33
    }
34
}
35