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
Push — master ( 71ffa7...3b4fde )
by Sebastian
03:42 queued 13s
created

PageViewProxy   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 22
c 1
b 0
f 0
dl 0
loc 51
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B main() 0 40 9
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\Plugin\Eid;
14
15
use Psr\Http\Message\ResponseInterface;
16
use Psr\Http\Message\ServerRequestInterface;
17
use TYPO3\CMS\Core\Http\Response;
18
use TYPO3\CMS\Core\Utility\GeneralUtility;
19
/**
20
 * eID image proxy for plugin 'Page View' of the 'dlf' extension
21
 *
22
 * @author Alexander Bigga <[email protected]>
23
 * @package TYPO3
24
 * @subpackage dlf
25
 * @access public
26
 */
27
class PageViewProxy
28
{
29
30
    /**
31
     * The main method of the eID script
32
     *
33
     * @access public
34
     *
35
     * @param ServerRequestInterface $request
36
     * @return ResponseInterface
37
     */
38
    public function main(ServerRequestInterface $request)
39
    {
40
        // header parameter for getUrl(); allowed values 0,1,2; default 0
41
        $header = (int)$request->getQueryParams()['header'];
42
        $header = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($header, 0, 2, 0);
43
44
        // the URI to fetch data or header from
45
        $url = (string)$request->getQueryParams()['url'];
46
        if (!GeneralUtility::isValidUrl($url)) {
47
            throw new \InvalidArgumentException('No valid url passed!', 1580482805);
48
        }
49
50
        // fetch the requested data or header
51
        $fetchedData = GeneralUtility::getUrl($url, $header);
52
53
        // Fetch header data separately to get "Last-Modified" info
54
        if ($header === 0) {
55
            $fetchedHeaderString = GeneralUtility::getUrl($url, 2);
56
            if (!empty($fetchedHeaderString)) {
57
                $fetchedHeader = explode("\n", $fetchedHeaderString);
58
                foreach ($fetchedHeader as $headerline) {
59
                    if (stripos($headerline, 'Last-Modified:') !== false) {
60
                        $lastModified = trim(substr($headerline, strpos($headerline, ':') + 1));
61
                        break;
62
                    }
63
                }
64
            }
65
        }
66
67
        // create response object
68
        /** @var Response $response */
69
        $response = GeneralUtility::makeInstance(Response::class);
70
        if ($fetchedData) {
71
            $response->getBody()->write($fetchedData);
72
            $response = $response->withHeader('Content-Type', finfo_buffer(finfo_open(FILEINFO_MIME), $fetchedData));
73
        }
74
        if ($header === 0 && !empty($lastModified)) {
75
            $response = $response->withHeader('Last-Modified', $lastModified);
76
        }
77
        return $response;
78
    }
79
}