Completed
Push — master ( 37faaa...541bbf )
by Raffael
10:18 queued 06:30
created

Http   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 100 %

Coupling/Cohesion

Components 0

Importance

Changes 0
Metric Value
wmc 4
dl 19
loc 19
rs 10
c 0
b 0
f 0
lcom 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ preAuthentication() 6 6 2
A __construct() 13 13 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * balloon
7
 *
8
 * @copyright   Copryright (c) 2012-2019 gyselroth GmbH (https://gyselroth.com)
9
 * @license     GPL-3.0 https://opensource.org/licenses/GPL-3.0
10
 */
11
12
namespace Balloon\App\Feedback\Constructor;
13
14
use Balloon\App\Feedback\Api\v2;
15
use Balloon\Hook;
16
use Balloon\Hook\AbstractHook;
17
use Micro\Auth\Adapter\None as AuthNone;
18
use Micro\Auth\Auth;
19
use Micro\Http\Router;
20
use Micro\Http\Router\Route;
21
22 View Code Duplication
class Http
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
{
24
    /**
25
     * Constructor.
26
     */
27
    public function __construct(Router $router, Hook $hook, Auth $auth)
0 ignored issues
show
Unused Code introduced by
The parameter $auth is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
    {
29
        $router->prependRoute(new Route('/api/v2/feedbacks', v2\Feedbacks::class));
30
31
        $hook->injectHook(new class() extends AbstractHook {
32
            public function preAuthentication(Auth $auth): void
33
            {
34
                if ('/index.php/api/v2/feedbacks' === $_SERVER['ORIG_SCRIPT_NAME']) {
35
                    $auth->injectAdapter(new AuthNone());
36
                }
37
            }
38
        });
39
    }
40
}
41