Completed
Push — master ( e4d2eb...4df581 )
by Nikola
02:47
created

BaseWidget::htmlAttribsToString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * This file is part of the Disqus Helper package.
4
 *
5
 * Copyright (c) Nikola Posa <[email protected]>
6
 *
7
 * For full copyright and license information, please refer to the LICENSE file,
8
 * located at the package root folder.
9
 */
10
11
namespace DisqusHelper\Widget;
12
13
/**
14
 * @author Nikola Posa <[email protected]>
15
 */
16
abstract class BaseWidget implements WidgetInterface
17
{
18 4
    protected function htmlAttribsToString(array $attribs) : string
19
    {
20 4
        $html = '';
21
22 4
        foreach ($attribs as $key => $val) {
23 4
            $key = htmlspecialchars($key, ENT_QUOTES);
24 4
            $val = htmlspecialchars($val, ENT_QUOTES);
25
26 4
            $html .= "$key=\"$val\" ";
27
        }
28
29 4
        $html = rtrim($html);
30
31 4
        return $html;
32
    }
33
}
34