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.

Manager   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 32.26 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 10
loc 31
rs 10
c 2
b 1
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getManager() 10 10 2
A getMyManager() 0 4 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
declare(strict_types = 1);
4
5
namespace Speicher210\KontaktIO\Resource;
6
7
use GuzzleHttp\Exception\ClientException;
8
use Speicher210\KontaktIO\AbstractResource;
9
use Speicher210\KontaktIO\Model\Manager as ManagerModel;
10
11
/**
12
 * Manager resource.
13
 */
14
class Manager extends AbstractResource
15
{
16
    /**
17
     * Get a manager.
18
     *
19
     * @param string $id The manager UUID.
20
     * @return ManagerModel
21
     * @throws \Speicher210\KontaktIO\Exception\ApiException
22
     */
23 View Code Duplication
    public function getManager($id): ManagerModel
0 ignored issues
show
Duplication introduced by
This method 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...
24
    {
25
        try {
26
            $response = $this->client->get('/manager/' . $id);
27
28
            return $this->serializer->deserialize($response->getBody(), ManagerModel::class, 'json');
29
        } catch (ClientException $e) {
30
            throw $this->createApiException($e);
31
        }
32
    }
33
34
    /**
35
     * Get the manager for the user owing the API key.
36
     *
37
     * @return ManagerModel
38
     * @throws \Speicher210\KontaktIO\Exception\ApiException
39
     */
40
    public function getMyManager(): ManagerModel
41
    {
42
        return $this->getManager('me');
43
    }
44
}
45