ProfileRequest::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 2
eloc 8
nc 2
nop 5
1
<?php namespace StarCraftApiClient\Requests;
2
3
use StarCraftApiClient\Client;
4
5
/**
6
 * @author neun
7
 * @since  2015-10-25
8
 */
9
class ProfileRequest extends Request
10
{
11
    /**
12
     * ProfileRequest constructor.
13
     * @param Client $client
14
     * @param string $type
15
     * @param int $id
16
     * @param string $name
17
     * @param string $region
18
     */
19
    public function __construct($client, $type, $id, $name, $region)
20
    {
21
        $url = 'https://%s.api.battle.net/sc2/profile/%s/1/%s/%s?locale=%s&apikey=%s';
22
23
        if (in_array($type, ['ladders', 'matches'])) {
24
            $this->url =
25
                sprintf($url, $region, $id, $name, $type, $client->language(), $client->apiToken());
26
        } else {
27
            $this->url =
28
                sprintf($url, $region, $id, $name, null, $client->language(), $client->apiToken());
29
        }
30
    }
31
}
32