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.

Issues (186)

Classes/Api/Viaf/Profile.php (1 issue)

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\Api\Viaf;
14
15
use Kitodo\Dlf\Common\Helper;
16
use TYPO3\CMS\Core\Http\RequestFactory;
17
use TYPO3\CMS\Core\Log\Logger;
18
use TYPO3\CMS\Core\Log\LogManager;
19
use TYPO3\CMS\Core\Utility\GeneralUtility;
20
21
/**
22
 * VIAF API Profile class
23
 *
24
 * @package TYPO3
25
 * @subpackage dlf
26
 *
27
 * @access public
28
 **/
29
class Profile
30
{
31
    /**
32
     * @access private
33
     * @var Logger This holds the logger
34
     */
35
    protected $logger;
36
37
    /**
38
     * @access private
39
     * @var Client This holds the client
40
     */
41
    private $client;
42
43
    /**
44
     * @access private
45
     * @var \SimpleXmlElement|false The raw VIAF profile or false if not found
46
     **/
47
    private $raw = false;
48
49
    /**
50
     * Constructs client instance
51
     *
52
     * @access public
53
     *
54
     * @param string $viaf the VIAF identifier of the profile
55
     *
56
     * @return void
57
     **/
58
    public function __construct(string $viaf)
59
    {
60
        $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class);
61
        $this->client = new Client($viaf, GeneralUtility::makeInstance(RequestFactory::class));
62
    }
63
64
    /**
65
     * Get the VIAF profile data
66
     *
67
     * @access public
68
     *
69
     * @return array|false
70
     **/
71
    public function getData()
72
    {
73
        $this->getRaw();
74
        if ($this->raw !== false && !empty($this->raw)) {
75
            $data = [];
76
            $data['address'] = $this->getAddress();
77
            $data['fullName'] = $this->getFullName();
78
            return $data;
79
        } else {
80
            $this->logger->warning('No data found for given VIAF URL');
81
            return false;
82
        }
83
    }
84
85
    /**
86
     * Get the address
87
     *
88
     * @access public
89
     *
90
     * @return string|false
91
     **/
92
    public function getAddress()
93
    {
94
        $this->getRaw();
95
        if ($this->raw !== false && !empty($this->raw->asXML())) {
96
            return (string) $this->raw->xpath('./ns1:nationalityOfEntity/ns1:data/ns1:text')[0];
97
        } else {
98
            $this->logger->warning('No address found for given VIAF URL');
99
            return false;
100
        }
101
    }
102
103
    /**
104
     * Get the full name
105
     *
106
     * @access public
107
     *
108
     * @return string|false
109
     **/
110
    public function getFullName()
111
    {
112
        $this->getRaw();
113
        if ($this->raw !== false && !empty($this->raw->asXML())) {
114
            $rawName = $this->raw->xpath('./ns1:mainHeadings/ns1:data/ns1:text');
115
            $name = (string) $rawName[0];
116
            $name = trim(trim(trim($name), ','), '.');
117
            return $name;
118
        } else {
119
            $this->logger->warning('No name found for given VIAF URL');
120
            return false;
121
        }
122
    }
123
124
    /**
125
     * Get the VIAF raw profile data
126
     *
127
     * @access private
128
     *
129
     * @return void
130
     **/
131
    private function getRaw(): void
132
    {
133
        $data = $this->client->getData();
134
        if ($data != false) {
135
            $this->raw = Helper::getXmlFileAsString($data);
136
            if ($this->raw != false && !empty($this->raw->asXML())) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
137
                $this->raw->registerXPathNamespace('ns1', 'http://viaf.org/viaf/terms#');
138
            }
139
        }
140
    }
141
}
142