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

TableColumnFormatter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 0
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
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