FrostFactory::api()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 3
crap 1
1
<?php
2
3
namespace CryptoPete\Frost;
4
5
use CryptoPete\Frost\Adapter\Http\GuzzleAdapter;
6
use CryptoPete\Frost\Adapter\Http\HttpInterface;
7
use CryptoPete\Frost\Adapter\Settings\DotenvAdapter;
8
use CryptoPete\Frost\Adapter\Settings\SettingsInterface;
9
use Dotenv\Dotenv;
10
use GuzzleHttp\Client;
11
12
/**
13
 * Class FrostFactory
14
 *
15
 * Simple factory methods to help speed up integration
16
 */
17
class FrostFactory
18
{
19
    /**
20
     * Simple convenience factory which can be overloaded or used with defaults
21
     *
22
     * @param string                 $env
23
     * @param SettingsInterface|null $settings
24
     * @param HttpInterface|null     $http
25
     *
26
     * @return FrostController
27
     */
28 1
    public function api(string $env = '.env', SettingsInterface $settings = null, HttpInterface $http = null): FrostController
29
    {
30 1
        $settings = $settings ?? new DotenvAdapter(new Dotenv(dirname(__DIR__), $env));
31 1
        $http = $http ?? new GuzzleAdapter(new Client);
32
33 1
        return new FrostController(
34 1
            $settings,
35 1
            $http
36
        );
37
    }
38
}
39