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

Client::getApiEndpoint()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 10
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\Orcid;
14
15
use TYPO3\CMS\Core\Http\RequestFactory;
16
use TYPO3\CMS\Core\Log\LogManager;
17
use TYPO3\CMS\Core\Utility\GeneralUtility;
18
19
/**
20
 * ORCID API Client class
21
 **/
22
class Client
23
{
24
    /**
25
     * constants for API endpoint
26
     **/
27
    const HOSTNAME  = 'orcid.org';
28
    const VERSION   = '3.0';
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 = 'record';
44
45
    /**
46
     * The ORCID API access level
47
     *
48
     * @var string
49
     **/
50
    private $level = 'pub';
51
52
    /**
53
     * The ORCID to search for
54
     *
55
     * @var string
56
     **/
57
    private $orcid = null;
58
59
    /**
60
     * The request object
61
     *
62
     * @var RequestFactoryInterface
0 ignored issues
show
Bug introduced by
The type Kitodo\Dlf\Api\Orcid\RequestFactoryInterface 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...
63
     **/
64
    private $requestFactory = null;
65
66
    /**
67
     * Constructs a new instance
68
     *
69
     * @param string $orcid: the ORCID to search for
70
     * @param RequestFactory $requestFactory a request object to inject
71
     * @return void
72
     **/
73
    public function __construct($orcid, RequestFactory $requestFactory)
74
    {
75
        $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class);
76
        $this->orcid = $orcid;
77
        $this->requestFactory = $requestFactory;
0 ignored issues
show
Documentation Bug introduced by
It seems like $requestFactory of type TYPO3\CMS\Core\Http\RequestFactory is incompatible with the declared type Kitodo\Dlf\Api\Orcid\RequestFactoryInterface of property $requestFactory.

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...
78
    }
79
80
    /**
81
     * @param string  $endpoint the shortname of the endpoint
82
     */
83
    public function setEndpoint($endpoint) {
84
        $this->endpoint = $endpoint;
85
    }
86
87
    /**
88
     * Get the profile data
89
     *
90
     * @return object
91
     * @throws Exception
92
     **/
93
    public function getData()
94
    {
95
        $url = $this->getApiEndpoint();
96
        try {
97
            $response = $this->requestFactory->request($url);
98
        } catch (\Exception $e) {
99
            $this->logger->warning('Could not fetch data from URL "' . $url . '". Error: ' . $e->getMessage() . '.');
100
            return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type object.
Loading history...
101
        }
102
        return $response->getBody()->getContents();
103
    }
104
105
    /**
106
     * Creates the qualified API endpoint for retrieving the desired data
107
     *
108
     * @param string  $endpoint the shortname of the endpoint
109
     * @return string
110
     **/
111
    private function getApiEndpoint()
112
    {
113
        $url  = 'https://' . $this->level . '.' .  self::HOSTNAME;
114
        $url .= '/v' . self::VERSION . '/';
115
        $url .= '0000-0001-9483-5161';
116
        //$url .= $this->orcid;
117
        $url .= '/' . $this->endpoint;
118
        return $url;
119
    }
120
}
121