Passed
Push — develop ( 2d7b42...b3143e )
by Brent
03:12
created

Header::getHtaccessHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Brendt\Stitcher\Site\Http;
4
5
class Header
6
{
7
    /**
8
     * @var string
9
     */
10
    private $name;
11
12
    /**
13
     * @var string
14
     */
15
    private $content;
16
17
    /**
18
     * Create a new header
19
     *
20
     * @param string $name
21
     * @param string $content
22
     *
23
     * @return Header
24
     */
25
    public static function create(string $name, string $content) : Header {
26
        return new self($name, $content);
27
    }
28
29
    /**
30
     * Create a Link header
31
     *
32
     * @param string $content
33
     *
34
     * @return Header
35
     */
36
    public static function link(string $content) : Header {
37
        return new self('Link', $content);
38
    }
39
40
    /**
41
     * Header constructor.
42
     *
43
     * @param string $name
44
     * @param string $content
45
     */
46
    public function __construct(string $name, string $content) {
47
        $this->name = $name;
48
        $this->content = $content;
49
    }
50
51
    /**
52
     * Get the header as string for .htaccess files
53
     *
54
     * @return string
55
     */
56
    public function getHtaccessHeader() : string {
57
        return "{$this->name} {$this->content}";
58
    }
59
60
    /**
61
     * Het the header as string
62
     *
63
     * @return string
64
     */
65
    public function __toString() : string {
66
        return "{$this->name}: {$this->content}";
67
    }
68
69
}
70