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 (#834)
by Beatrycze
03:29
created

Client::getData()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 0
dl 0
loc 10
rs 10
c 0
b 0
f 0
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 Psr\Http\Message\RequestFactoryInterface;
16
use TYPO3\CMS\Core\Http\RequestFactory;
17
use TYPO3\CMS\Core\Log\LogManager;
18
use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20
/**
21
 * VIAF API Client class
22
 *
23
 * @author Beatrycze Volk <[email protected]>
24
 * @package TYPO3
25
 * @subpackage dlf
26
 * @access public
27
 **/
28
class Client
29
{
30
    /**
31
     * This holds the logger
32
     *
33
     * @var LogManager
34
     * @access protected
35
     */
36
    protected $logger;
37
38
    /**
39
     * The ORCID API endpoint
40
     *
41
     * @var string
42
     **/
43
    private $endpoint = 'viaf.xml';
44
45
    /**
46
     * The VIAF URL for the profile
47
     *
48
     * @var string
49
     **/
50
    private $viafUrl = null;
51
52
    /**
53
     * The request object
54
     *
55
     * @var RequestFactoryInterface
56
     **/
57
    private $requestFactory = null;
58
59
    /**
60
     * Constructs a new instance
61
     *
62
     * @param string $viaf: the VIAF identifier of the profile
63
     * @param RequestFactory $requestFactory a request object to inject
64
     * @return void
65
     **/
66
    public function __construct($viaf, RequestFactory $requestFactory)
67
    {
68
        $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class);
69
        $this->viafUrl = 'http://viaf.org/viaf/' . $viaf;
70
        $this->requestFactory = $requestFactory;
71
    }
72
73
    /**
74
     * Sets API endpoint
75
     *
76
     * @param string  $endpoint the shortname of the endpoint
77
     *
78
     * @return void
79
     */
80
    public function setEndpoint($endpoint) {
81
        $this->endpoint = $endpoint;
82
    }
83
84
    /**
85
     * Get the profile data
86
     *
87
     * @return object|bool
88
     **/
89
    public function getData()
90
    {
91
        $url = $this->getApiEndpoint();
92
        try {
93
            $response = $this->requestFactory->request($url);
94
        } catch (\Exception $e) {
95
            $this->logger->warning('Could not fetch data from URL "' . $url . '". Error: ' . $e->getMessage() . '.');
96
            return false;
97
        }
98
        return $response->getBody()->getContents();
99
    }
100
101
    /**
102
     * Creates the qualified API endpoint for retrieving the desired data
103
     *
104
     * @return string
105
     **/
106
    protected function getApiEndpoint()
107
    {
108
        return $this->viafUrl . '/' . $this->endpoint;
109
    }
110
}
111