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

Text   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A formatContent() 0 17 5
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