Test Failed
Push — 6-0 ( cfb4d5 )
by Tomas Norre
03:23
created

AuthenticationService   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getUser() 0 8 2
A authUser() 0 7 3
1
<?php
2
namespace AOE\Crawler\Service;
3
4
/***************************************************************
5
 *  Copyright notice
6
 *
7
 *  (c) 2016 AOE GmbH <[email protected]>
8
 *
9
 *  All rights reserved
10
 *
11
 *  This script is part of the TYPO3 project. The TYPO3 project is
12
 *  free software; you can redistribute it and/or modify
13
 *  it under the terms of the GNU General Public License as published by
14
 *  the Free Software Foundation; either version 3 of the License, or
15
 *  (at your option) any later version.
16
 *
17
 *  The GNU General Public License can be found at
18
 *  http://www.gnu.org/copyleft/gpl.html.
19
 *
20
 *  This script is distributed in the hope that it will be useful,
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 *  GNU General Public License for more details.
24
 *
25
 *  This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27
28
use TYPO3\CMS\Sv\AbstractAuthenticationService;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Sv\AbstractAuthenticationService 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...
29
30
/**
31
 * Class AuthenticationService
32
 *
33
 * @package AOE\Crawler\Service
34
 */
35
class AuthenticationService extends AbstractAuthenticationService
36
{
37
38
    /**
39
     * Find user by HTTP_X_T3CRAWLER Header
40
     *
41
     * @return mixed user array or false
42
     */
43
    public function getUser()
44
    {
45
        $user = false;
46
        if (isset($_SERVER['HTTP_X_T3CRAWLER'])) {
47
            $user = $this->fetchUserRecord('_cli_crawler');
48
        }
49
50
        return $user;
51
    }
52
53
    /**
54
     * Authenticate user
0 ignored issues
show
Bug introduced by
The type AOE\Crawler\Service\user 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...
55
     *
56
     * @param array user
57
     *
58
     * @return int 100="don't know", 0="no", 200="yes"
59
     */
60
    public function authUser(array $user)
61
    {
62
        if (isset($_SERVER['HTTP_X_T3CRAWLER'])) {
63
            return ($user['username'] == '_cli_crawler') ? 200 : 100;
64
        }
65
66
        return 100;
67
    }
68
}
69