FormatterHelper::formatSections()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace Glooby\Debug\Formatter;
4
5
/**
6
 * @author Emil Kilhage
7
 */
8
class FormatterHelper
9
{
10
    /**
11
     * @param array $sections
12
     * @return string
13
     */
14
    public static function formatSections(array $sections)
15
    {
16
        $sectionsFormatted = [];
17
18
        foreach ($sections as $k => $v) {
19
            $sectionsFormatted[] = sprintf("%s\n%s\n%s", $k, str_repeat('-', strlen($k)), trim($v));
20
        }
21
22
        $text = implode("\n\n", $sectionsFormatted) . "\n";
23
24
        return $text;
25
    }
26
}
27