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

Capitalizer::applyCurrent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

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