Completed
Push — master ( bb097f...e1bfb5 )
by Brian
01:09
created

Proficiencies   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 9 9 2
A __call() 5 5 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 Darkgoldblade01\Dnd5eApi\Api;
4
5
use Darkgoldblade01\Dnd5eApi\Dnd5eApi;
6
use Darkgoldblade01\Dnd5eApi\Models\Proficiencies as ProficienciesModel;
7
use Darkgoldblade01\Dnd5eApi\NotFoundException;
8
use GuzzleHttp\Exception\GuzzleException;
9
10
/**
11
 * Class Skills
12
 * @package Darkgoldblade01\Dnd5eApi\Api
13
 */
14 View Code Duplication
class Proficiencies extends Dnd5eApi
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...
15
{
16
17
    /**
18
     * @var string
19
     */
20
    protected $base_uri = 'https://www.dnd5eapi.co/api/proficiencies/';
21
22
    /**
23
     * @return array
24
     * @throws GuzzleException|NotFoundException
25
     */
26
    public function all(): array
27
    {
28
        $response = [];
29
        $items = $this->get('');
30
        foreach($items['results'] AS $item) {
31
            $response[] = (new ProficienciesModel())->fill($this->get($item['index']));
32
        }
33
        return $response;
34
    }
35
36
    /**
37
     * @param $name
38
     * @param $arguments
39
     * @return ProficienciesModel
40
     * @throws GuzzleException|NotFoundException
41
     */
42
    public function __call($name, $arguments): ProficienciesModel
43
    {
44
        $response = $this->get($name);
45
        return (new ProficienciesModel())->fill($response);
46
    }
47
48
49
}
50