Completed
Push — master ( db2ac8...31d1c8 )
by Brian
01:13
created

Languages::all()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Darkgoldblade01\Dnd5eApi\Api;
4
5
use Darkgoldblade01\Dnd5eApi\Dnd5eApi;
6
use Darkgoldblade01\Dnd5eApi\Models\Languages as LanguagesModel;
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 Languages 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/languages/';
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 LanguagesModel())->fill($this->get($item['index']));
32
        }
33
        return $response;
34
    }
35
36
    /**
37
     * @param $name
38
     * @param $arguments
39
     * @return LanguagesModel
40
     * @throws GuzzleException|NotFoundException
41
     */
42
    public function __call($name, $arguments): LanguagesModel
43
    {
44
        $response = $this->get($name);
45
        return (new LanguagesModel())->fill($response);
46
    }
47
48
49
}
50