ColumnLeftContainer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 65
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getHtml() 0 22 3
A setColumnWidth() 0 4 1
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\Core;
22
23
/** 
24
 * Class ColumnLeftContainer
25
 * Use in layout builder like TwoColumnRow
26
 */
27
class ColumnLeftContainer extends HtmlContainerElement
28
{
29
    /** 
30
     * The width of the column
31
     * Default is 0 to tell no column width set (auto)
32
     * 
33
     * @access private
34
     * @var int    $columnWidth
35
     */
36
    protected $columnWidth = 0;
37
38
    /** 
39
     * Sets the column width
40
     * 
41
     * @access public 
42
     * @param int           $width      The column width in pixels
43
     * 
44
     * @return $this
45
     */
46
    public function setColumnWidth(int $width)
47
    {
48
        $this->columnWidth = $width;
49
        return $this;
50
    }
51
52
    /**
53
     * Constructor
54
     * 
55
     * @param HtmlElement   $parent
56
     */
57
    public function __construct(HtmlElement $parent)
58
    {
59
        $this->parent = $parent;
60
    }
61
62
    /** 
63
     * Gets the HTML 
64
     *
65
     * @access public
66
     * @param string    $indent
67
     * 
68
     * @return string   The html string content
69
     */
70
    public function getHtml(string $indent)
71
    {
72
       $html  = $indent . '<td align="left" valign="top" class="flexibleContainerBox">'. PHP_EOL;
73
       $html .= $indent . '  <table border="0" cellpadding="'. $this->cellPadding .'" cellspacing="0"' . 
74
                                    ($this->columnWidth == 0 ? '' : ' width="' . $this->columnWidth . '"') .
75
                                   ' bgcolor="'. $this->getEffectiveStyle('background-color') .'"'.  
76
                                   ' style="max-width:100%;">'.PHP_EOL;
77
       $html .= $indent . '    <tr>'.PHP_EOL;
78
       $html .= $indent . '      <td align="'. $this->horizontalAlign .'" valign="'. $this->verticalAlign .'" class="textContent">'.PHP_EOL;
79
80
       // render child elements collection
81
       foreach ($this->elements() as $element){
82
            $html .= $element->getHtml($indent . '        ');
83
            $html .= PHP_EOL ;
84
       }
85
86
       $html .= $indent . '      </td>'.PHP_EOL;
87
       $html .= $indent . '    </tr>'.PHP_EOL;
88
       $html .= $indent . '  </table>'.PHP_EOL;
89
       $html .= $indent . '</td>'.PHP_EOL;
90
91
       return $html;
92
    }
93
94
}