HtmlHelper::cssStyleFromArray()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 3
nc 4
nop 1
1
<?php
2
namespace Itstructure\GridView\Helpers;
3
4
/**
5
 * Class HtmlHelper
6
 * @package Itstructure\GridView\Helpers
7
 */
8
class HtmlHelper
9
{
10
    /**
11
     * @param $content
12
     * @param string $charset
13
     * @param bool $doubleEncode
14
     * @return string
15
     */
16
    public static function encode($content, $charset = 'UTF-8', $doubleEncode = true)
17
    {
18
        return htmlspecialchars($content, ENT_QUOTES | ENT_SUBSTITUTE, $charset, $doubleEncode);
19
    }
20
21
    /**
22
     * @param array $style
23
     * @return null|string
24
     */
25
    public static function cssStyleFromArray(array $style)
26
    {
27
        $output = '';
28
        foreach ($style as $name => $value) {
29
            $output .= "$name: $value; ";
30
        }
31
32
        return $output === '' ? null : rtrim($output);
33
    }
34
}
35