Passed
Branch master (d0211e)
by Willy
02:44
created

WorldOfWarcraftApiFactory::getAchievementApi()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Kubinashi\BattlenetApi\WorldOfWarcraft;
4
5
use Kubinashi\BattlenetApi\Model\AuthenticationModel;
6
use Kubinashi\BattlenetApi\Service\RequestService;
7
use Kubinashi\BattlenetApi\WorldOfWarcraft\AchievementApi\AchievementApi;
8
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\CharacterProfileApi;
9
10
/**
11
 * @author  Willy Reiche
12
 * @since   2017-07-21
13
 * @version 1.0
14
 */
15
class WorldOfWarcraftApiFactory
16
{
17
    /**
18
     * @var AuthenticationModel
19
     */
20
    private static $authenticationModel;
21
22
    /**
23
     * @var RequestService
24
     */
25
    private static $requestService;
26
27
    /**
28
     * WorldOfWarcraftApi constructor.
29
     *
30
     * @param string $apiKey
31
     * @param string $locale
32
     * @param string $region
33
     */
34 2
    public function __construct($apiKey, $locale, $region)
35
    {
36 2
        self::$authenticationModel = new AuthenticationModel($apiKey, $locale, $region);
37 2
        self::$requestService = new RequestService();
38 2
    }
39
40
    /**
41
     * @param string $charName
42
     * @param string $realm
43
     *
44
     * @return CharacterProfileApi
45
     */
46 1
    public static function getCharacterApi($charName, $realm)
47
    {
48 1
        return new CharacterProfileApi(
49 1
            self::$authenticationModel,
50 1
            self::$requestService,
51 1
            $charName,
52
            $realm
53 1
        );
54
    }
55
56
    public static function getAchievementApi()
57
    {
58
        return new AchievementApi(
59
            self::$authenticationModel,
60
            self::$requestService
61
        );
62
    }
63
}