Payload::setPostData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
namespace VideoPublisher\Payload;
3
4
/**
5
 * Class Payload.
6
 *
7
 * @author Bart Malestein <[email protected]>
8
 */
9
class Payload
10
{
11
12
    /**
13
     * @var array
14
     */
15
    protected $data = array();
16
17
    /**
18
     * @var array
19
     */
20
    protected $headers = array();
21
22
    /**
23
     * @var string
24
     */
25
    protected $url;
26
27
    /**
28
     * @var string
29
     */
30
    protected $method;
31
32
    /**
33
     * Payload constructor.
34
     * @param string $url
35
     * @param string $method
36
     */
37
    public function __construct($url, $method = 'post')
38
    {
39
        $this->url = $url;
40
        $this->method = $method;
41
    }
42
43
    /**
44
     * @param $url
45
     * @return $this
46
     */
47
    public function setUrl($url)
48
    {
49
        $this->url = $url;
50
        return $this;
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function getUrl()
57
    {
58
        return $this->url;
59
    }
60
61
    /**
62
     * @param $header
63
     * @param $value
64
     * @return $this
65
     */
66
    public function setHeader($header, $value)
67
    {
68
        $this->headers[$header] = $value;
69
        return $this;
70
    }
71
72
    /**
73
     * @return array
74
     */
75
    public function getHeaders()
76
    {
77
        return $this->headers;
78
    }
79
80
    /**
81
     * @param array $data
82
     */
83
    public function overwritePostData(array $data)
84
    {
85
        $this->data = $data;
86
    }
87
88
    /**
89
     * @param $key
90
     * @param $value
91
     * @return $this
92
     */
93
    public function setPostData($key, $value)
94
    {
95
        $this->data[$key] = $value;
96
        return $this;
97
    }
98
99
    /**
100
     * @return array
101
     */
102
    public function getPostData()
103
    {
104
        return $this->data;
105
    }
106
107
    /**
108
     * @param $method
109
     * @return $this
110
     */
111
    public function setMethod($method)
112
    {
113
        $this->method = $method;
114
        return $this;
115
    }
116
117
    /**
118
     * @return string
119
     */
120
    public function getMethod()
121
    {
122
        return $this->method;
123
    }
124
}
125