Test Failed
Pull Request — master (#2)
by Pol
03:30
created

BaseExample   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
cbo 2
dl 0
loc 37
ccs 0
cts 16
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 3
A getRandomOrgAPI() 0 4 1
A getHttpClient() 0 4 1
1
<?php
2
3
namespace drupol\Yaroc\Examples;
4
5
use drupol\Yaroc\RandomOrgAPI;
6
use Http\Adapter\Guzzle6\Client;
7
8
abstract class BaseExample
9
{
10
    /**
11
     * The Random.org API bridge.
12
     *
13
     * @var \drupol\Yaroc\RandomOrgAPI
14
     */
15
    private $randomOrgAPI;
16
17
    /**
18
     * BaseExample constructor.
19
     */
20
    public function __construct()
21
    {
22
        $key = '00000000-0000-0000-0000-000000000000';
23
        if (file_exists('./apikey') && $fileKey = file_get_contents('./apikey')) {
24
            $key = $fileKey;
25
        }
26
27
        $this->randomOrgAPI = (new RandomOrgAPI([]))->withApiKey($key);
28
    }
29
30
    /**
31
     * Get the Random.org API bridge.
32
     *
33
     * @return \drupol\Yaroc\RandomOrgAPI
34
     */
35
    public function getRandomOrgAPI()
36
    {
37
        return $this->randomOrgAPI;
38
    }
39
40
    public function getHttpClient()
41
    {
42
        return new Client();
43
    }
44
}
45