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

ExternOGMapperTrait::mapLienwebFromMeta()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 43
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 32
nc 1
nop 1
dl 0
loc 43
rs 9.408
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 ExternOGMapperTrait
15
{
16
    /**
17
     * Mapping from Open Graph and Dublin Core meta tags
18
     * https://ogp.me/
19
     * https://www.dublincore.org/schemas/
20
     * todo extract DC ?
21
     *
22
     * @param array $meta
23
     *
24
     * @return array
25
     */
26
    protected function mapLienwebFromMeta(array $meta): array
27
    {
28
        return [
29
            'DATA-TYPE' => 'Open Graph/Dublin Core',
30
            'DATA-ARTICLE' => $this->isAnArticle($meta['og:type'] ?? ''),
31
            'site' => $this->clean($meta['og:site_name'] ?? null),
32
            'titre' => $this->clean($meta['og:title'] ?? $meta['twitter:title'] ?? $meta['DC.title'] ?? null),
33
            'url' => $meta['og:url'] ?? $meta['URL'] ?? null,
34
            'langue' => $this->convertLangue(
35
                $meta['og:locale'] ?? $meta['DC.language'] ?? $meta['citation_language'] ?? null
36
            ),
37
            'consulté le' => date('d-m-Y'),
38
            'auteur' => $this->clean(
39
                $meta['og:article:author'] ?? $meta['article:author'] ?? $meta['citation_author'] ?? null
40
            ),
41
            'format' => $this->convertOGtype2format($meta['og:type'] ?? null),
42
            'date' => $this->convertDate(
43
                $meta['og:article:published_time'] ??
44
                $meta['article:published_time'] ?? $meta['DC.date'] ?? $meta['citation_date'] ?? null
45
            ),
46
            'url-access' => $this->convertURLaccess($meta),
47
48
            // DUBLIN CORE ONLY
49
            'périodique' => $this->clean($meta['DC.isPartOf'] ?? $meta['citation_journal_title'] ?? null),
50
            'et al.' => $this->authorsEtAl(
51
                $meta['citation_authors'] ?? $meta['DC.Contributor'] ?? null,
52
                true
53
            ),
54
            'auteur1' => $this->wikifyPressAgency(
55
                $this->clean(
56
                    $this->authorsEtAl(
57
                        $meta['citation_authors'] ?? $meta['DC.Contributor'] ?? null
58
                    )
59
                )
60
            ),
61
            'volume' => $meta['citation_volume'] ?? null,
62
            'numéro' => $meta['citation_issue'] ?? null,
63
            'page' => $this->convertDCpage($meta),
64
            'doi' => $meta['citation_doi'] ?? null,
65
            'éditeur' => $meta['DC.publisher'] ?? null, // Persée dégeulasse todo?
66
            'pmid' => $meta['citation_pmid'] ?? null,
67
            'issn' => $meta["citation_issn"] ?? null,
68
            'isbn' => $meta["citation_isbn"] ?? null,
69
            // "prism.eIssn" => "2262-7197"
70
        ];
71
    }
72
}
73