Passed
Push — main ( 834936...e5772d )
by Michael
11:48
created

TableColumnFormatter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 22
ccs 5
cts 5
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A format() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MichaelRubel\Formatters\Collection;
6
7
use Illuminate\Support\Str;
8
use MichaelRubel\Formatters\Formatter;
9
10
class TableColumnFormatter implements Formatter
11
{
12
    /**
13
     * @param string|null $string
14
     */
15 6
    public function __construct(
16
        public ?string $string = null
17
    ) {
18
    }
19
20
    /**
21
     * Format the snake-cased attributes in readable format for the tables.
22
     *
23
     * @return string
24
     */
25 6
    public function format(): string
26
    {
27 6
        return Str::ucfirst(
28 6
            Str::replace(
29
                '_',
30
                ' ',
31 6
                $this->string
32
            )
33
        );
34
    }
35
}
36