Passed
Branch dev (1a31b5)
by Dispositif
03:03
created

WebLDMapperTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A mapArticleDataFromJSONLD() 0 15 1
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 WebLDMapperTrait
15
{
16
    protected function mapArticleDataFromJSONLD(array $jsonLD): array
17
    {
18
        return [
19
            'DATA-TYPE' => 'JSON-LD',
20
            'DATA-ARTICLE' => $jsonLD['@type'] === 'NewsArticle',
21
            'périodique' => $jsonLD['publisher']['name'] ?? null,
22
            'titre' => $this->clean($jsonLD['headline']), // obligatoire
1 ignored issue
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
            'titre' => $this->/** @scrutinizer ignore-call */ clean($jsonLD['headline']), // obligatoire
Loading history...
23
            'url' => $jsonLD['url'] ?? $jsonLD['mainEntityOfPage']['@id'] ?? null,
24
            'date' => $this->convertDate($jsonLD['datePublished'] ?? $jsonLD['dateCreated'] ?? null), //
1 ignored issue
show
Bug introduced by
It seems like convertDate() 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

24
            'date' => $this->/** @scrutinizer ignore-call */ convertDate($jsonLD['datePublished'] ?? $jsonLD['dateCreated'] ?? null), //
Loading history...
25
            // 2020-03-19T19:13:01.000Z
26
            'auteur1' => $this->wikifyPressAgency($this->convertAuteur($jsonLD, 0)),
2 ignored issues
show
Bug introduced by
It seems like wikifyPressAgency() 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

26
            'auteur1' => $this->/** @scrutinizer ignore-call */ wikifyPressAgency($this->convertAuteur($jsonLD, 0)),
Loading history...
Bug introduced by
It seems like convertAuteur() 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

26
            'auteur1' => $this->wikifyPressAgency($this->/** @scrutinizer ignore-call */ convertAuteur($jsonLD, 0)),
Loading history...
27
            'auteur2' => $this->convertAuteur($jsonLD, 1),
28
            'auteur3' => $this->convertAuteur($jsonLD, 2),
29
            'auteur institutionnel' => $this->convertInstitutionnel($jsonLD),
1 ignored issue
show
Bug introduced by
It seems like convertInstitutionnel() 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

29
            'auteur institutionnel' => $this->/** @scrutinizer ignore-call */ convertInstitutionnel($jsonLD),
Loading history...
30
            'url-access' => $this->convertURLaccess($jsonLD),
1 ignored issue
show
Bug introduced by
It seems like convertURLaccess() 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

30
            'url-access' => $this->/** @scrutinizer ignore-call */ convertURLaccess($jsonLD),
Loading history...
31
        ];
32
    }
33
}
34