Passed
Push — master ( e4fd87...194c77 )
by Magnar Ovedal
04:26 queued 01:34
created

Capitalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 10
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A applyCurrent() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stadly\PasswordPolice\WordFormatter;
6
7
use Traversable;
8
9
final class Capitalizer extends ChainableFormatter
10
{
11
    /**
12
     * @param iterable<string> $words Words to format.
13
     * @return Traversable<string> The words with the first character in upper case and the rest in lower case.
14
     */
15 4
    protected function applyCurrent(iterable $words): Traversable
16
    {
17 4
        foreach ($words as $word) {
18 4
            yield mb_strtoupper(mb_substr($word, 0, 1)).mb_strtolower(mb_substr($word, 1));
19
        }
20 4
    }
21
}
22