Completed
Push — master ( a8687a...737d23 )
by Joachim
07:33
created

Response::__construct()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.0261

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 7
cp 0.8571
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 2
nop 1
crap 3.0261
1
<?php declare(strict_types=1);
2
namespace Loevgaard\Linkmobility\Response;
3
4
abstract class Response implements ResponseInterface
5
{
6
    protected $data;
7
8
    /**
9
     * @var bool
10
     */
11
    protected $successful;
12
13 1
    public function __construct($data)
14
    {
15 1
        $this->successful = true;
16 1
        $this->data = $data;
17
18 1
        if (is_array($data) && isset($data['errors'])) {
19
            $this->successful = false;
20
        } else {
21 1
            $this->init();
22
        }
23 1
    }
24
25
    /**
26
     * @return bool
27
     */
28
    public function isSuccessful(): bool
29
    {
30
        return $this->successful;
31
    }
32
}
33