RowImage::getHtml()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 56
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 37
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 56
rs 9.328

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
/**
24
 * Class RowImage
25
 * A row with full width image
26
 */
27
class RowImage extends Row
28
{
29
     /**
30
     * @access private
31
     * @var Image   $image
32
     */
33
    private $image = null;
34
35
     /**
36
     * Constructor
37
     * 
38
     * @access public
39
     * @param Image     $img
40
     */
41
    public function __construct(Image $img)
42
    {
43
        $this->add($img);
44
        $this->image = $img;
45
    }
46
47
    /** 
48
     * Sets the image max height 
49
     *
50
     * @access public
51
     * @param int       $value
52
     * 
53
     * @return void
54
     */   
55
    public function setMaxHeight(int $value)
56
    {
57
        $this->imageMaxHeight = $value;
0 ignored issues
show
Bug Best Practice introduced by
The property imageMaxHeight does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
58
    }
59
60
    /** 
61
     * Gets the HTML 
62
     *
63
     * @access public
64
     * @param string    $indent
65
     * 
66
     * @return string   The html string content
67
     */
68
    public function getHtml(string $indent)
69
    {
70
        // html result. start with an empty string or a html comment
71
        $html  = $this->getBuilder()->getHtmlComment('ROW IMAGE CONTAINER' . ' //', $indent);
72
     
73
        $html .= $indent . '<tr>'.PHP_EOL;
74
        $html .= $indent . '  <td align="center" valign="top">'.PHP_EOL;
75
76
        $html .= $this->getBuilder()->getHtmlComment('CENTERING TABLE //', $indent . '    ');
77
78
        $html .= $indent . '    <table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="'. $this->getEffectiveStyle('background-color').'">'.PHP_EOL;
79
        $html .= $indent . '      <tr '.$this->getRowStyle() .'>'.PHP_EOL;
80
        $html .= $indent . '        <td align="center" valign="top">'.PHP_EOL;
81
82
        $html .= $this->getBuilder()->getHtmlComment('FLEXIBLE CONTAINER //', $indent . '          ');
83
84
        $html .= $indent . '          <table border="0" cellspacing="0" cellpadding="' . $this->cellPadding . 
85
                                        '" bgcolor="'. $this->getEffectiveStyle('background-color').
86
                                        '" width="'. $this->getBuilder()->emailBodyWidth() . 
87
                                        '" class="flexibleContainer">'.PHP_EOL;
88
        $html .= $indent . '            <tr>'.PHP_EOL;
89
        $html .= $indent . '              <td '. $this->getRowStyle() .
90
                                              ' align="center" valign="top" width="'. $this->getBuilder()->emailBodyWidth() . 
91
                                              '" class="flexibleContainerCell">'.PHP_EOL;
92
93
        $html .= $this->getBuilder()->getHtmlComment('CONTENT TABLE //', $indent . '               ');
94
        
95
        $html .= $indent . '                <table border="0" cellpadding="0" cellspacing="0" width="100%">'.PHP_EOL;
96
        $html .= $indent . '                  <tr>'.PHP_EOL;
97
        $html .= $indent . '                    <td valign="top" class="imageContent" color="'. $this->getEffectiveStyle('color') . '" bgcolor="'. $this->getEffectiveStyle('background-color') . '">'.PHP_EOL;
98
99
        $html .= $this->image->getHtml($indent . '                      ').PHP_EOL;;
100
101
        $html .= $indent . '                    </td>'.PHP_EOL;
102
        $html .= $indent . '                  </tr>'.PHP_EOL;
103
        $html .= $indent . '                </table>'.PHP_EOL;
104
        
105
        $html .= $this->getBuilder()->getHtmlComment('// CONTENT TABLE', $indent . '               ');
106
107
        $html .= $indent . '              </td>'.PHP_EOL;
108
        $html .= $indent . '            </tr>'.PHP_EOL;
109
        $html .= $indent . '          </table>'.PHP_EOL;
110
111
        $html .= $this->getBuilder()->getHtmlComment('// FLEXIBLE CONTAINER', $indent . '          ');
112
113
        $html .= $indent . '        </td>'.PHP_EOL;
114
        $html .= $indent . '      </tr>'.PHP_EOL;
115
        $html .= $indent . '    </table>'.PHP_EOL;
116
117
        $html .= $this->getBuilder()->getHtmlComment('// CENTERING TABLE', $indent . '    ');
118
119
        $html .= $indent . '  </td>'.PHP_EOL;
120
        $html .= $indent . '</tr>'.PHP_EOL;
121
122
        $html .= $this->getBuilder()->getHtmlComment('// ' . 'ROW IMAGE CONTAINER', $indent);
123
        return $html;
124
    }
125
    
126
}