PayloadFactory::createPayload()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace VideoPublisher\Payload;
4
5
/**
6
 * Class PayloadFactory.
7
 *
8
 * @author Bart Malestein <[email protected]>
9
 */
10
class PayloadFactory
11
{
12
    /**
13
     * @var string
14
     */
15
    private $baseUrl;
16
17
    /**
18
     * PayloadFactory constructor.
19
     * @param string $baseUrl
20
     */
21
    public function __construct($baseUrl)
22
    {
23
        $this->baseUrl = rtrim($baseUrl, '/');
24
    }
25
26
    /**
27
     * @param string $path
28
     * @return Payload
29
     */
30
    public function post($path)
31
    {
32
        return $this->createPayload($path, 'post');
33
    }
34
35
    /**
36
     * @param string $path
37
     * @return Payload
38
     */
39
    public function put($path)
40
    {
41
        return $this->createPayload($path, 'put');
42
    }
43
44
    /**
45
     * @param string $path
46
     * @return Payload
47
     */
48
    public function get($path)
49
    {
50
        return $this->createPayload($path, 'get');
51
    }
52
53
    /**
54
     * @param string $path
55
     * @param string $method
56
     * @return Payload
57
     */
58
    public function createPayload($path, $method)
59
    {
60
        return new Payload($this->baseUrl . '/' . ltrim($path, '/'), $method);
61
    }
62
}