generateAndSendReportForCustomers()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 5
Ratio 62.5 %

Importance

Changes 0
Metric Value
dl 5
loc 8
c 0
b 0
f 0
rs 10
cc 2
nc 2
nop 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * File: CliReportManager.php
6
 *
7
 * @author      Maciej Sławik <[email protected]>
8
 * Github:      https://github.com/maciejslawik
9
 */
10
11
namespace MSlwk\ReactPhpPlayground\Model\Report;
12
13
use MSlwk\ReactPhpPlayground\Api\Report\ReportGeneratorInterface;
14
use MSlwk\ReactPhpPlayground\Api\Report\CliReportManagerInterface;
15
use MSlwk\ReactPhpPlayground\Api\Report\ReportSenderInterface;
16
17
/**
18
 * Class CliReportManager
19
 * @package MSlwk\ReactPhpPlayground\Model\Report
20
 */
21
class CliReportManager implements CliReportManagerInterface
22
{
23
    /**
24
     * @var ReportGeneratorInterface
25
     */
26
    private $reportGenerator;
27
28
    /**
29
     * @var ReportSenderInterface
30
     */
31
    private $reportSender;
32
33
    /**
34
     * CliReportManager constructor.
35
     * @param ReportGeneratorInterface $reportGenerator
36
     * @param ReportSenderInterface $reportSender
37
     */
38
    public function __construct(
39
        ReportGeneratorInterface $reportGenerator,
40
        ReportSenderInterface $reportSender
41
    ) {
42
        $this->reportGenerator = $reportGenerator;
43
        $this->reportSender = $reportSender;
44
    }
45
46
    /**
47
     * @param int[] $customerIds
48
     * @return void
49
     */
50
    public function generateAndSendReportForCustomers(array $customerIds): void
51
    {
52 View Code Duplication
        foreach ($customerIds as $customerId) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
            $report = $this->reportGenerator->generateReport($customerId);
54
            $this->reportSender->sendReport($report);
55
            echo "Reporting process finished for customer: {$customerId}\n";
56
        }
57
    }
58
}
59