RowTwoColumns::getHtml()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 61
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 40
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 61
rs 9.28

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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\HtmlElements;
22
23
use Kristuff\Phtemail\Core\ColumnLeftContainer;
24
use Kristuff\Phtemail\Core\ColumnRightContainer;
25
use Kristuff\Phtemail\Core\HtmlElement;
26
27
/** 
28
 * Class RowTwoColumns
29
 */
30
class RowTwoColumns extends HtmlElement
31
{
32
    /** 
33
     * Allow to set padding and remove top/bottom padding
34
     */
35
    use \Kristuff\Phtemail\Core\ContainerPaddingTrait;
36
37
    
38
    /** 
39
     * The first column
40
     * 
41
     * @access private
42
     * @var ColumnLeftContainer    $leftCol
43
     */
44
    protected $leftCol = null;
45
46
    /** 
47
     * The second column
48
     * 
49
     * @access private
50
     * @var ColumnRightContainer   $rightCol
51
     */
52
    protected $rightCol = null;
53
54
    /** 
55
     * Gets the first column
56
     * 
57
     * @access public 
58
     * @return ColumnLeftContainer
59
     */
60
    public function leftColumn()
61
    {
62
        return $this->leftCol;
63
    }
64
65
    /** 
66
     * Gets the second column
67
     * 
68
     * @access public 
69
     * @return ColumnRightContainer
70
     */
71
    public function rightColumn()
72
    {
73
        return $this->rightCol;
74
    }
75
76
    /**
77
     * Constructor
78
     * 
79
     * @access public
80
     */
81
    public function __construct()
82
    {
83
        $this->leftCol = new ColumnLeftContainer($this);
84
        $this->rightCol = new ColumnRightContainer($this);
85
        $this->leftCol->setPadding(0);
86
        $this->rightCol->setPadding(0);
87
    }
88
89
    /** 
90
     * Gets the HTML 
91
     *
92
     * @access public
93
     * @param string        $indent
94
     * 
95
     * @return string       The html string content
96
     */
97
    public function getHtml(string $indent)
98
    {
99
        // html result. start with an empty string or a html comment
100
        $html  = $this->getBuilder()->getHtmlComment('ROW TWO COLUMNS CONTAINER' . ' //', $indent);
101
     
102
        $html .= $indent . '<tr>'.PHP_EOL;
103
        $html .= $indent . '  <td align="center" valign="top">'.PHP_EOL;
104
105
        $html .= $this->getBuilder()->getHtmlComment('CENTERING TABLE //', $indent . '    ');
106
107
        $html .= $indent . '    <table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="'. $this->getEffectiveStyle('background-color').'">'.PHP_EOL;
108
        $html .= $indent . '      <tr'. $this->getRowStyle() .'>'.PHP_EOL;
109
        $html .= $indent . '        <td align="center" valign="top">'.PHP_EOL;
110
111
        $html .= $this->getBuilder()->getHtmlComment('FLEXIBLE CONTAINER //', $indent . '          ');
112
113
        $html .= $indent . '          <table border="0" cellspacing="0" cellpadding="'. $this->cellPadding . 
114
                                        '" bgcolor="'. $this->getEffectiveStyle('background-color').
115
                                        '" width="'. $this->getBuilder()->emailBodyWidth() . 
116
                                        '" class="flexibleContainer">'.PHP_EOL;
117
        $html .= $indent . '            <tr>'.PHP_EOL;
118
        $html .= $indent . '              <td'.$this->getRowStyle().
119
                                              ' align="center" valign="top" width="'. $this->getBuilder()->emailBodyWidth() . 
120
                                              '" class="flexibleContainerCell">'.PHP_EOL;
121
122
        $html .= $this->getBuilder()->getHtmlComment('CONTENT TABLE //', $indent . '               ');
123
        
124
        $html .= $indent . '                <table border="0" cellpadding="0" cellspacing="0" width="100%">'.PHP_EOL;
125
        $html .= $indent . '                  <tr>'.PHP_EOL;
126
127
        $html .= $this->getBuilder()->getHtmlComment('COLUMN LEFT //', $indent . '                    ');
128
        $html .= $this->leftColumn()->getHtml($indent . '                    ');
129
        $html .= $this->getBuilder()->getHtmlComment('// COLUMN LEFT', $indent . '                    ');
130
131
        $html .= $this->getBuilder()->getHtmlComment('COLUMN RIGHT //', $indent. '                    ');
132
        $html .= $this->rightColumn()->getHtml($indent . '                    ');
133
        $html .= $this->getBuilder()->getHtmlComment('// COLUMN RIGHT', $indent. '                    ');
134
135
136
        $html .= $indent . '                  </tr>'.PHP_EOL;
137
        $html .= $indent . '                </table>'.PHP_EOL;
138
        
139
        $html .= $this->getBuilder()->getHtmlComment('// CONTENT TABLE', $indent . '               ');
140
141
        $html .= $indent . '              </td>'.PHP_EOL;
142
        $html .= $indent . '            </tr>'.PHP_EOL;
143
        $html .= $indent . '          </table>'.PHP_EOL;
144
145
        $html .= $this->getBuilder()->getHtmlComment('// FLEXIBLE CONTAINER', $indent . '          ');
146
147
        $html .= $indent . '        </td>'.PHP_EOL;
148
        $html .= $indent . '      </tr>'.PHP_EOL;
149
        $html .= $indent . '    </table>'.PHP_EOL;
150
151
        $html .= $this->getBuilder()->getHtmlComment('// CENTERING TABLE', $indent . '    ');
152
153
        $html .= $indent . '  </td>'.PHP_EOL;
154
        $html .= $indent . '</tr>'.PHP_EOL;
155
156
        $html .= $this->getBuilder()->getHtmlComment('// ' . 'ROW TWO COLUMNS CONTAINER', $indent);
157
        return $html;
158
    }
159
    
160
}