Div   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 44
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getHtml() 0 11 2
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
 * Represents the <div> html element
25
 */
26
class Div extends \Kristuff\Phtemail\Core\HtmlContainerElement
27
{
28
    /**
29
     * Constructor
30
     * 
31
     * @access public
32
     * @param  array    $styles         The inline styles
33
     */
34
    public function __construct(array $styles = [])
35
    {
36
        $this->setStyles($styles);
37
        $this->mandatoryStyles = array(
38
            'color',   
39
            'font-family',
40
            'font-size',
41
            'padding-top',
42
            'padding-bottom',
43
            'padding-left',
44
            'padding-right',
45
           // 'font-weight', todo
46
           // 'line-height',
47
        );
48
49
    }
50
51
    /** 
52
     * Gets the HTML 
53
     *
54
     * @access public
55
     * @param string    $indent
56
     * 
57
     * @return string   The html string content
58
     */
59
    public function getHtml(string $indent)
60
    {
61
       $html  = $indent . '<div'. $this->getInlineStyles() . '>'. PHP_EOL;
62
63
       // render child elements collection
64
       foreach ($this->elements() as $element){
65
           $html .= $element->getHtml($indent . '  '). PHP_EOL ;
66
       }
67
68
       $html .= $indent . '</div>'.PHP_EOL;
69
       return $html;
70
    }
71
72
}