Completed
Push — master ( 9f3eac...f0c1b5 )
by David
02:49 queued 13s
created

Response::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Wordlift\Api;
4
5
class Response {
6
7
	private $response;
8
9
	/**
10
	 * @var int|string
11
	 */
12
	private $code;
13
14
	/**
15
	 * @var bool
16
	 */
17
	private $is_success;
18
19
	/**
20
	 * @var string
21
	 */
22
	private $body;
23
24
	public function __construct( $response ) {
25
26
		$this->response   = $response;
27
		$this->code       = wp_remote_retrieve_response_code( $this->response );
28
		$this->is_success = ! empty( $this->code ) && 2 === (int) $this->code / 100;
29
		$this->body       = wp_remote_retrieve_body( $this->response );
30
31
	}
32
33
	public function is_success() {
34
35
		return $this->is_success;
36
37
	}
38
39
	public function get_body() {
40
41
		return $this->body;
42
	}
43
44
}
45