Passed
Push — master ( 0deb8f...f54565 )
by Goffy
04:13
created

Request::isMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Wggithub\Github\Http;
4
5
use XoopsModules\Wggithub\Github;
6
7
8
/**
9
 * HTTP request envelope.
10
 *
11
 * @author  Miloslav Hůla (https://github.com/milo)
12
 */
13
class Request extends Message
14
{
15
	/** HTTP request method */
16
	const
17
		DELETE = 'DELETE',
18
		GET = 'GET',
19
		HEAD = 'HEAD',
20
		PATCH = 'PATCH',
21
		POST = 'POST',
22
		PUT = 'PUT';
23
24
25
	/** @var string */
26
	private $method;
27
28
	/** @var string */
29
	private $url;
30
31
32
	/**
33
	 * @param  string
34
	 * @param  string
35
	 * @param  array
36
	 * @param  string|NULL
37
	 */
38
	public function __construct($method, $url, array $headers = [], $content = NULL)
39
	{
40
		$this->method = $method;
41
		$this->url = $url;
42
		parent::__construct($headers, $content);
43
	}
44
45
46
	/**
47
	 * @param  string
48
	 * @return bool
49
	 */
50
	public function isMethod($method)
51
	{
52
		return strcasecmp($this->method, $method) === 0;
53
	}
54
55
56
	/**
57
	 * @return string
58
	 */
59
	public function getMethod()
60
	{
61
		return $this->method;
62
	}
63
64
65
	/**
66
	 * @return string
67
	 */
68
	public function getUrl()
69
	{
70
		return $this->url;
71
	}
72
73
74
	/**
75
	 * @param  string
76
	 * @param  string
77
	 * @return self
78
	 */
79
	public function addHeader($name, $value)
80
	{
81
		return parent::addHeader($name, $value);
82
	}
83
84
85
	/**
86
	 * @param  string
87
	 * @param  string|NULL
88
	 * @return self
89
	 */
90
	public function setHeader($name, $value)
91
	{
92
		return parent::setHeader($name, $value);
93
	}
94
95
}
96