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:32
created

Client::setEndpoint()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
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 Psr\Log\LoggerAwareInterface;
16
use Psr\Log\LoggerAwareTrait;
17
use TYPO3\CMS\Core\Http\RequestFactory;
18
19
/**
20
 * ORCID API Client class
21
 **/
22
class Client implements LoggerAwareInterface
23
{
24
    use LoggerAwareTrait;
25
26
    /**
27
     * constants for API endpoint
28
     **/
29
    const HOSTNAME  = 'orcid.org';
30
    const VERSION   = '3.0';
31
32
    /**
33
     * The ORCID API endpoint
34
     *
35
     * @var string
36
     **/
37
    private $endpoint = 'record';
38
39
    /**
40
     * The ORCID API access level
41
     *
42
     * @var string
43
     **/
44
    private $level = 'pub';
45
46
    /**
47
     * The ORCID to search for
48
     *
49
     * @var string
50
     **/
51
    private $orcid = null;
52
53
    /**
54
     * The request object
55
     *
56
     * @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...
57
     **/
58
    private $requestFactory = null;
59
60
    /**
61
     * Constructs a new instance
62
     *
63
     * @param string $orcid: the ORCID to search for
64
     * @param RequestFactory $requestFactory a request object to inject
65
     * @return void
66
     **/
67
    public function __construct($orcid, RequestFactory $requestFactory)
68
    {
69
        $this->orcid = $orcid;
70
        $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...
71
    }
72
73
    /**
74
     * @param string  $endpoint the shortname of the endpoint
75
     */
76
    public function setEndpoint($endpoint) {
77
        $this->endpoint = $endpoint;
78
    }
79
80
    /**
81
     * Get the profile data
82
     *
83
     * @return object
84
     * @throws Exception
85
     **/
86
    public function getData()
87
    {
88
        $url = $this->getApiEndpoint();
89
        try {
90
            $response = $this->requestFactory->request($url);
91
        } catch (\Exception $e) {
92
            $this->logger->warning('Could not fetch data from URL "' . $url . '". Error: ' . $e->getMessage() . '.');
93
            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...
94
        }
95
        return $response->getBody()->getContents();
96
    }
97
98
    /**
99
     * Creates the qualified API endpoint for retrieving the desired data
100
     *
101
     * @param string  $endpoint the shortname of the endpoint
102
     * @return string
103
     **/
104
    private function getApiEndpoint()
105
    {
106
        $url  = 'https://' . $this->level . '.' .  self::HOSTNAME;
107
        $url .= '/v' . self::VERSION . '/';
108
        $url .= '0000-0001-9483-5161';
109
        //$url .= $this->orcid;
110
        $url .= '/' . $this->endpoint;
111
        return $url;
112
    }
113
}
114