Test Failed
Push — master ( 9d73a2...14c4f6 )
by hugh
06:42
created

Endpoint::makeUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
namespace HughCube\ACMClient;
4
5
use HughCube\PUrl\Url;
6
7
/**
8
 * Class Endpoint
9
 * @package HughCube\ACMClient
10
 */
11
class Endpoint
12
{
13
    /**
14
     * 请求地址
15
     *
16
     * @var string
17
     */
18
    private $host;
19
20
    /**
21
     * 请求端口
22
     *
23
     * @var integer
24
     */
25
    private $port;
26
27
    /**
28
     * Endpoint constructor.
29
     * @param string $host
30
     * @param int $port
31
     */
32
    public function __construct($host, $port)
33
    {
34
        $this->host = $host;
35
        $this->port = empty($port) ? 8080 : $port;
36
    }
37
38
    /**
39
     * 生成完整URL
40
     *
41
     * @param string $path
42
     * @return Url
43
     */
44
    public function makeUrl(string $path)
45
    {
46
        return Url::instance()
47
            ->withHost($this->host)
48
            ->withPort($this->port)
49
            ->withPath($path);
50
    }
51
}
52