Client::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 2
rs 10
1
<?php
2
3
namespace SchoppAx\Sleeper\Http;
4
5
use GuzzleHttp\Handler\MockHandler;
6
use GuzzleHttp\HandlerStack;
7
8
class Client extends \GuzzleHttp\Client {
9
  private const API_BASE = "https://api.sleeper.app/v1/";
10
11 17
  public function __construct(MockHandler $mock = NULL)
12
  {
13 17
    if ($mock) {
14 16
      $handlerStack = HandlerStack::create($mock);
15 16
      parent::__construct(['handler' => $handlerStack]);
16
    } else {
17 1
      parent::__construct([
18 1
        'base_uri' => self::API_BASE,
19
        'headers' => [
20
          'Content-Type' => 'application/json'
21
        ]
22
      ]);
23
    }
24 17
  }
25
26
}
27