Passed
Push — main ( 90c8f5...cf7c53 )
by Daniel
01:54
created

UpperCaseWordsFormatter::format()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace RoadBunch\StringBean;
5
6
7
class UpperCaseWordsFormatter extends AbstractFormatter
8
{
9
    public function __construct(
10
        private string|array $delimiter = [" ", "-", "_", "."],
11
    ) {}
12
13
    public function format(string $string): string
14
    {
15
        $delimiter = is_string($this->delimiter) ? [$this->delimiter] : $this->delimiter;
16
        return ucwords($string, implode('', $delimiter));
17
    }
18
}
19