PlayerProfileEndpointController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 36
loc 36
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A getPlayer() 10 10 1

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
namespace Ps2alerts\Api\Controller\Endpoint\Profiles;
4
5
use Ps2alerts\Api\Controller\Endpoint\AbstractEndpointController;
6
use Ps2alerts\Api\Repository\Metrics\PlayerTotalRepository;
7
use Ps2alerts\Api\Transformer\Profiles\PlayerProfileTransformer;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Psr\Http\Message\ResponseInterface;
10
11 View Code Duplication
class PlayerProfileEndpointController extends AbstractEndpointController
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...
12
{
13
    /**
14
     * Construct
15
     *
16
     * @param PlayerTotalRepository    $playerTotalRepo
17
     * @param PlayerProfileTransformer $playerProfileTransformer
18
     */
19
    public function __construct(
20
        PlayerTotalRepository    $playerTotalRepo,
21
        PlayerProfileTransformer $playerProfileTransformer
22
    ) {
23
        $this->repository = $playerTotalRepo;
24
        $this->transformer = $playerProfileTransformer;
25
    }
26
27
    /**
28
     * Gets a player
29
     *
30
     * @param  ServerRequestInterface $request
31
     * @param  ResponseInterface      $response
32
     * @param  array                  $args
33
     *
34
     * @return ResponseInterface
35
     */
36
    public function getPlayer(ServerRequestInterface $request, ResponseInterface $response, array $args)
0 ignored issues
show
Unused Code introduced by
The parameter $request 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...
Unused Code introduced by
The parameter $response 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...
37
    {
38
        $player = $this->repository->readSinglebyId($args['id']);
39
40
        return $this->respond(
41
            'item',
42
            $player,
43
            $this->transformer
44
        );
45
    }
46
}
47