ReportSender   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 17
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 7 2
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusStockMovementPlugin\Sender;
6
7
use Setono\SyliusStockMovementPlugin\Model\ReportConfigurationInterface;
8
use Setono\SyliusStockMovementPlugin\Model\ReportInterface;
9
use Setono\SyliusStockMovementPlugin\Transport\TransportInterface;
10
use Sylius\Component\Registry\ServiceRegistryInterface;
11
12
final class ReportSender implements ReportSenderInterface
13
{
14
    /** @var ServiceRegistryInterface */
15
    private $transportRegistry;
16
17
    public function __construct(ServiceRegistryInterface $transportRegistry)
18
    {
19
        $this->transportRegistry = $transportRegistry;
20
    }
21
22
    public function send(string $file, ReportInterface $report, ReportConfigurationInterface $reportConfiguration): void
23
    {
24
        foreach ($reportConfiguration->getTransports() as $reportConfigurationTransport) {
25
            /** @var TransportInterface $transport */
26
            $transport = $this->transportRegistry->get($reportConfigurationTransport->getType());
27
28
            $transport->send($file, $reportConfigurationTransport->getConfiguration(), $report, $reportConfiguration);
29
        }
30
    }
31
}
32