Completed
Push — develop ( 1d4633...83eb6a )
by David
02:35 queued 10s
created

Response   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A is_success() 0 5 1
A get_body() 0 4 1
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