Passed
Pull Request — master (#195)
by
unknown
09:41 queued 02:26
created

ExternalMetadata::getDataXpath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
rs 10
1
<?php
2
namespace EWW\Dpf\Domain\Model;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
/**
18
 * ExternalMetadata
19
 */
20
abstract class ExternalMetadata extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
21
{
22
    /**
23
     * feUser
24
     *
25
     * @var int
26
     */
27
    protected $feUser = 0;
28
29
    /**
30
     * @var string
31
     */
32
    protected $source = '';
33
34
    /**
35
     * data
36
     *
37
     * @var string
38
     */
39
    protected $data = '';
40
41
    /**
42
     * @var string
43
     */
44
    protected $publicationIdentifier = '';
45
46
    /**
47
     * @return string
48
     */
49
50
    public abstract function getTitle(): string;
51
    /**
52
     * @return array
53
     */
54
    public abstract function getPersons(): array;
55
56
    /**
57
     * @return string
58
     */
59
    public abstract function getPublicationType(): string;
60
61
    /**
62
     * @return string
63
     */
64
    public abstract function getYear(): string;
65
66
    /**
67
     * @return int
68
     */
69
    public function getFeUser(): int
70
    {
71
        return $this->feUser;
72
    }
73
74
    /**
75
     * @param int $feUser
76
     */
77
    public function setFeUser(int $feUser)
78
    {
79
        $this->feUser = $feUser;
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    public function getSource(): string
86
    {
87
        return $this->source;
88
    }
89
90
    /**
91
     * @param string $source
92
     */
93
    public function setSource(string $source)
94
    {
95
        $this->source = $source;
96
    }
97
98
    /**
99
     * @return string
100
     */
101
    public function getData(): string
102
    {
103
        return $this->data;
104
    }
105
106
107
    /**
108
     * @param string $data
109
     */
110
    public function setData(string $data)
111
    {
112
        $this->data = $data;
113
    }
114
115
    /**
116
     * @return string
117
     */
118
    public function getPublicationIdentifier(): string
119
    {
120
        return $this->publicationIdentifier;
121
    }
122
123
    /**
124
     * @param string $publicationIdentifier
125
     */
126
    public function setPublicationIdentifier(string $publicationIdentifier)
127
    {
128
        $this->publicationIdentifier = trim($publicationIdentifier);
129
    }
130
131
    /**
132
     * @return \DOMXPath
133
     * @throws \Exception
134
     */
135
    public function getDataXpath()
136
    {
137
        $dom = new \DOMDocument();
138
        if (is_null(@$dom->loadXML($this->data))) {
139
            throw new \Exception("Invalid XML: ".get_class($this));
140
        }
141
        return \EWW\Dpf\Helper\XPath::create($dom);
142
    }
143
}
144