Completed
Push — master ( 49833f...63cd37 )
by Andrii
14:54
created

Text::formatContent()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.3888
c 0
b 0
f 0
cc 5
nc 5
nop 2
1
<?php
2
3
namespace hiapi\Core\Console\Formatter;
4
5
use Lcobucci\ContentNegotiation\ContentFormatter;
6
7
final class Text extends ContentFormatter
8
{
9
    public function formatContent($content, $attributes = []): string
10
    {
11
        if (\is_string($content)) {
12
            return $content;
13
        }
14
15
        if (!\is_array($content)) {
16
            return \var_export($content, true);
17
        }
18
19
        $res = '';
20
        foreach ($content as $k => $v) {
21
            $res .= $k.': ' . (\is_array($v) ? \implode(',', $v) : $v) . "\n";
22
        }
23
24
        return $res;
25
    }
26
}
27