Passed
Pull Request — master (#19)
by
unknown
01:50
created

ClashOfClansApi   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPlayerByTag() 0 6 1
1
<?php
2
3
namespace ClashApi
4
{
5
    use ClashApi\DataAccessLayer\WebClient;
6
    use ClashApi\Models\Player;
7
8
    class ClashOfClansApi
9
    {
10
        /**
11
         * @var WebClient to perform requests to the Clash Of Clans API
12
         */
13
        protected $webClient;
14
15
        /**
16
         * @var string  apikey  Every call to the Clash Of Clans API needs to contain an Api Key
17
         */
18
        public function __construct($apiKey)
19
        {
20
            $this->webClient = new WebClient($apiKey);
21
        }
22
23
        /**
24
         * 
25
         * @var string The player's tag (with the hasttag)
26
         */
27
        public function getPlayerByTag($tag)
28
        {
29
            $response = $this->webClient->sendRequest('/players/' . $tag);
30
31
            return new Player($response);
32
        }
33
    }
34
}