EmailBodyContainer::getHtml()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 10
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 22
rs 9.9332
1
<?php
2
3
/**
4
 *  ____  _     _                       _ _
5
 * |  _ \| |__ | |_ ___ _ __ ___   __ _(_) |
6
 * | |_) | '_ \| __/ _ \ '_ ` _ \ / _` | | |
7
 * |  __/| | | | ||  __/ | | | | | (_| | | |
8
 * |_|   |_| |_|\__\___|_| |_| |_|\__,_|_|_|
9
 *
10
 * This file is part of Kristuff\Phtemail.
11
 *
12
 * (c) Kristuff <[email protected]>
13
 *
14
 * For the full copyright and license information, please view the LICENSE
15
 * file that was distributed with this source code.
16
 *
17
 * @version    0.2.0
18
 * @copyright  2017-2020 Kristuff
19
 */
20
21
namespace Kristuff\Phtemail;
22
23
/** 
24
 * Class EmailBodyContainer
25
 * The main container element inside the HtmlEmailBuilder
26
 */
27
class EmailBodyContainer extends \Kristuff\Phtemail\Core\HtmlBuilderContainer
28
{
29
    /** 
30
     * Sets the default padding for all created row in body
31
     * Current default value is 30 pixels
32
     *
33
     * @access public
34
     * @param int       $value      The padding in pixels
35
     * 
36
     * @return void   
37
     */
38
    public function setDefaultRowPadding(int $value)
39
    {
40
        $this->cellPadding = $value;
41
    }
42
43
    /** 
44
     * Gets the HTML 
45
     *
46
     * @access public
47
     * @param string    $indent
48
     * 
49
     * @return string   The html string content
50
     */
51
    public function getHtml(string $indent)
52
    {
53
54
        // html result. start with an empty string or a html comment
55
        $html  = $this->getBuilder()->getHtmlComment('EMAIL BODY' . ' //', $indent);
56
            
57
        // create a table container
58
        $html .= $indent . '<table bgcolor="'.$this->getBuilder()->emailBodyBackground() . '"' 
59
                                . ' width="'. $this->getBuilder()->emailBodyWidth() . '"'  
60
                                . ' border="0" cellpadding="0" cellspacing="0" id="emailBody">' .PHP_EOL;
61
62
        // render child elements collection
63
        foreach ($this->childElements as $element){
64
            $html .= $element->getHtml($indent . '  ') .PHP_EOL ;
65
        }
66
67
        $html .= $indent . '</table>'.PHP_EOL;
68
        $html .= $this->getBuilder()->getHtmlComment('// ' . 'EMAIL BODY', $indent);
69
        $html .= PHP_EOL;
70
71
        // done
72
        return $html;
73
74
    }
75
}