Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#690)
by
unknown
02:58
created

Model3D::getMetadata()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 23
rs 9.7998
cc 3
nc 2
nop 2
1
<?php
2
3
/**
4
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
5
 *
6
 * This file is part of the Kitodo and TYPO3 projects.
7
 *
8
 * @license GNU General Public License version 3 or later.
9
 * For the full copyright and license information, please read the
10
 * LICENSE.txt file that was distributed with this source code.
11
 */
12
13
namespace Kitodo\Dlf\Common\Document;
14
15
use Kitodo\Dlf\Format\Item;
0 ignored issues
show
Bug introduced by
The type Kitodo\Dlf\Format\Item was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
17
use TYPO3\CMS\Core\Utility\GeneralUtility;
18
19
/**
20
 * Model3D class for the 'dlf' extension.
21
 *
22
 * @author Beatrycze Volk <[email protected]>
23
 * @package TYPO3
24
 * @subpackage dlf
25
 * @access public
26
 */
27
final class Model3D extends Document
28
{
29
    /**
30
     * The extension key
31
     *
32
     * @var string
33
     * @static
34
     * @access public
35
     */
36
    public static $extKey = 'dlf';
37
38
    /**
39
     * This holds the XML file's ITEM part as \SimpleXMLElement object
40
     *
41
     * @var \SimpleXMLElement
42
     * @access protected
43
     */
44
    protected $item;
45
46
    /**
47
     * {@inheritDoc}
48
     * @see Document::getDownloadLocation($id)
49
     */
50
    public function getDownloadLocation($id)
51
    {
52
        // Nothing to do here, at the moment
53
    }
54
55
    /**
56
     * {@inheritDoc}
57
     * @see Document::getFileLocation($id)
58
     */
59
    public function getFileLocation($id)
60
    {
61
        // Nothing to do here, at the moment
62
    }
63
64
    /**
65
     * {@inheritDoc}
66
     * @see Document::getFileMimeType($id)
67
     */
68
    public function getFileMimeType($id)
69
    {
70
        // Nothing to do here, at the moment
71
    }
72
73
    /**
74
     * {@inheritDoc}
75
     * @see Document::getFileLocation($id)
76
     */
77
    public function getLogicalStructure($id, $recursive = false)
78
    {
79
        // Nothing to do here, at the moment
80
    }
81
82
    /**
83
     * {@inheritDoc}
84
     * @see Document::getMetadata($id, $cPid = 0)
85
     */
86
    public function getMetadata($id, $cPid = 0)
87
    {
88
        // Get metadata from parsed metadata array if available.
89
        if (
90
            !empty($this->metadataArray[$id])
91
            && $this->metadataArray[0] == $cPid
92
        ) {
93
            return $this->metadataArray[$id];
94
        }
95
        // Initialize metadata array with empty values.
96
        $metadata = [
97
            'title' => [],
98
            'description' => [],
99
            'author' => [],
100
            'preview_image' => [],
101
            'upload' => [],
102
            'document_format' => ['ITEM']
103
        ];
104
105
        $item = GeneralUtility::makeInstance(Item::class);
106
        $item->extractMetadata($this->xml, $metadata);
107
108
        return $metadata;
109
    }
110
111
    /**
112
     * {@inheritDoc}
113
     * @see Document::establishRecordId($pid)
114
     */
115
    protected function establishRecordId($pid)
116
    {
117
        // Nothing to do here, at the moment
118
    }
119
120
    /**
121
     * {@inheritDoc}
122
     * @see Document::getDocument()
123
     */
124
    protected function getDocument()
125
    {
126
        return $this->item;
127
    }
128
129
    /**
130
     * {@inheritDoc}
131
     * @see Document::init()
132
     */
133
    protected function init()
134
    {
135
        // Get ITEM node from XML file.
136
        $item = $this->xml->xpath('/response/item[@key="0"]');
137
        if (!empty($item)) {
138
            $this->item = $item;
0 ignored issues
show
Documentation Bug introduced by
It seems like $item of type array<mixed,SimpleXMLElement> is incompatible with the declared type SimpleXMLElement of property $item.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
139
        } else {
140
            $this->logger->error('No ITEM part found in document with UID ' . $this->uid);
1 ignored issue
show
Bug introduced by
The method error() does not exist on TYPO3\CMS\Core\Log\LogManager. ( Ignorable by Annotation )

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

140
            $this->logger->/** @scrutinizer ignore-call */ 
141
                           error('No ITEM part found in document with UID ' . $this->uid);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
141
        }
142
    }
143
144
    /**
145
     * {@inheritDoc}
146
     * @see Document::loadLocation($location)
147
     */
148
    protected function loadLocation($location)
149
    {
150
        $xml = $this->loadXMLLocation($location);
151
        // Set some basic properties.
152
        if ($xml !== false) {
153
            $this->xml = $xml;
0 ignored issues
show
Documentation Bug introduced by
It seems like $xml of type string or true is incompatible with the declared type SimpleXMLElement of property $xml.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
154
            return true;
155
        }
156
        return false;
157
    }
158
159
    /**
160
     * {@inheritDoc}
161
     * @see Document::getParentDocumentUidForSaving($pid, $core, $owner)
162
     */
163
    protected function getParentDocumentUidForSaving($pid, $core, $owner)
164
    {
165
        // Nothing to do here, at the moment
166
    }
167
168
    /**
169
     * {@inheritDoc}
170
     * @see Document::prepareMetadataArray($cPid)
171
     */
172
    protected function prepareMetadataArray($cPid)
173
    {
174
        // Nothing to do here, at the moment
175
    }
176
177
    /**
178
     * {@inheritDoc}
179
     * @see Document::setPreloadedDocument($preloadedDocument)
180
     */
181
    protected function setPreloadedDocument($preloadedDocument)
182
    {
183
        // Nothing to do here, at the moment
184
    }
185
186
    /**
187
     * {@inheritDoc}
188
     * @see Document::_getPhysicalStructure()
189
     */
190
    protected function _getPhysicalStructure()
191
    {
192
        // Nothing to do here, at the moment
193
    }
194
195
    /**
196
     * {@inheritDoc}
197
     * @see Document::_getSmLinks()
198
     */
199
    protected function _getSmLinks()
200
    {
201
        // Nothing to do here, at the moment
202
    }
203
204
    /**
205
     * {@inheritDoc}
206
     * @see Document::_getThumbnail($forceReload = false)
207
     */
208
    protected function _getThumbnail($forceReload = false)
209
    {
210
        // Nothing to do here, at the moment
211
    }
212
213
    /**
214
     * {@inheritDoc}
215
     * @see Document::_getToplevelId()
216
     */
217
    protected function _getToplevelId()
218
    {
219
        // Nothing to do here, at the moment
220
    }
221
}