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

Header   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 65
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A link() 0 3 1
A __construct() 0 4 1
A getHtaccessHeader() 0 3 1
A __toString() 0 3 1
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