Combiner   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 30
ccs 8
cts 8
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A applyCurrent() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stadly\PasswordPolice\DateFormatter;
6
7
use DateTimeInterface;
8
use Stadly\PasswordPolice\CharTree;
9
use Stadly\PasswordPolice\DateFormatter;
10
11
final class Combiner implements DateFormatter
12
{
13
    use Chaining;
14
15
    /**
16
     * @var array<DateFormatter> Date formatters.
17
     */
18
    private $dateFormatters;
19
20
    /**
21
     * @param array<DateFormatter> $dateFormatters Date formatters.
22
     */
23 2
    public function __construct(array $dateFormatters)
24
    {
25 2
        $this->dateFormatters = $dateFormatters;
26 2
    }
27
28
    /**
29
     * @param iterable<DateTimeInterface> $dates Dates to format.
30
     * @return CharTree The dates formatted by all the date formatters in the combiner.
31
     */
32 2
    protected function applyCurrent(iterable $dates): CharTree
33
    {
34 2
        $charTrees = [];
35
36 2
        foreach ($this->dateFormatters as $dateFormatter) {
37 2
            $charTrees[] = $dateFormatter->apply($dates);
38
        }
39
40 2
        return CharTree::fromArray($charTrees);
41
    }
42
}
43