HtmlString   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 51
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setHtmlContent() 0 13 2
A getHtmlContent() 0 4 1
1
<?php namespace Luminaire\Premailer;
2
3
/**
4
 * Created by Sublime Text 3
5
 *
6
 * @user     Kevin Tanjung
7
 * @website  http://kevintanjung.github.io
8
 * @email    [email protected]
9
 * @date     02/08/2016
10
 * @time     11:09
11
 */
12
13
use InvalidArgumentException;
14
15
/**
16
 * The "HTML String based Premailer" class
17
 *
18
 * @package  \Luminaire\Premailer
19
 */
20
class HtmlString extends BasePremailer
21
{
22
23
    /**
24
     * The HTML source file content
25
     *
26
     * @var string
27
     */
28
    protected $content;
29
30
    /**
31
     * Create a new instance of "HTML String Premailer"
32
     *
33
     * @param  string  $htmlContent
34
     */
35
    public function __construct($htmlContent)
36
    {
37
        $this->setHtmlContent($htmlContent);
38
    }
39
40
    /**
41
     * Sets the HTML content
42
     *
43
     * @param  string  $htmlContent
44
     * @return $this
45
     */
46
    protected function setHtmlContent($htmlContent)
47
    {
48
        if (is_string($htmlContent))
49
        {
50
            $this->content = $htmlContent;
51
        }
52
        else
53
        {
54
            throw new InvalidArgumentException("Invalid type '" . gettype($htmlContent). "' for argument 'htmlContent' given.");
55
        }
56
57
        return $this;
58
    }
59
60
    /**
61
     * Gets the HTML content from the preferred source.
62
     *
63
     * @return string
64
     */
65
    protected function getHtmlContent()
66
    {
67
        return $this->content;
68
    }
69
70
}
71