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.
Completed
Push — master ( 90c912...99a750 )
by Sebastian
14s queued 11s
created

SearchSuggest::main()   B

Complexity

Conditions 7
Paths 3

Size

Total Lines 33
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 22
c 3
b 0
f 0
dl 0
loc 33
rs 8.6346
cc 7
nc 3
nop 1
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 Kitodo\Dlf\Common\Helper;
16
use Kitodo\Dlf\Common\Solr;
17
use Psr\Http\Message\ResponseInterface;
18
use Psr\Http\Message\ServerRequestInterface;
19
use TYPO3\CMS\Core\Http\Response;
20
use TYPO3\CMS\Core\Utility\GeneralUtility;
21
22
/**
23
 * eID search suggestions for plugin 'Search' of the 'dlf' extension
24
 *
25
 * @author Henrik Lochmann <[email protected]>
26
 * @author Sebastian Meyer <[email protected]>
27
 * @package TYPO3
28
 * @subpackage dlf
29
 * @access public
30
 */
31
class SearchSuggest
32
{
33
    /**
34
     * The main method of the eID script
35
     *
36
    *  @param ServerRequestInterface $request
37
     * @return ResponseInterface XML response of search suggestions
38
     */
39
    public function main(ServerRequestInterface $request)
40
    {
41
        $output = [];
42
        // Get input parameters and decrypt core name.
43
        $parameters = $request->getParsedBody();
44
        $encrypted = (string) $parameters['encrypted'];
45
        $hashed = (string) $parameters['hashed'];
46
        if (empty($encrypted) || empty($hashed)) {
47
            throw new \InvalidArgumentException('No valid parameter passed!', 1580585079);
48
        }
49
        $core = Helper::decrypt($encrypted, $hashed);
50
        // Perform Solr query.
51
        $solr = Solr::getInstance($core);
52
        if ($solr->ready) {
53
            $query = $solr->service->createSelect();
54
            $query->setHandler('suggest');
55
            $query->setQuery(Solr::escapeQuery((string) $parameters['q']));
56
            $query->setRows(0);
57
            $results = $solr->service->select($query)->getResponse()->getBody();
58
            $result = json_decode($results);
59
            foreach ($result->spellcheck->suggestions as $suggestions) {
60
                if (is_object($suggestions)) {
61
                    foreach ($suggestions->suggestion as $suggestion) {
62
                        $output[] = $suggestion;
63
                    }
64
                }
65
            }
66
        }
67
        // Create response object.
68
        /** @var Response $response */
69
        $response = GeneralUtility::makeInstance(Response::class);
70
        $response->getBody()->write(json_encode($output));
71
        return $response;
72
    }
73
}
74