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

BaseExample::getRandomOrgAPI()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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