SaveReport   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 14 1
1
<?php
2
3
namespace T4web\Cron\Listener;
4
5
use T4web\Cron\JobEndedEvent;
6
use T4web\Cron\Log\LoggerInterface;
7
8
class SaveReport
9
{
10
    /**
11
     * @var LoggerInterface
12
     */
13
    private $logger;
14
15
    public function __construct(LoggerInterface $logger)
16
    {
17
        $this->logger = $logger;
18
    }
19
20
    public function __invoke(JobEndedEvent $e)
21
    {
22
        $report = $e->getReport();
23
24
        $this->logger->log(
25
            $e->getJob()->getId(),
26
            $report->getStartTime(),
27
            $report->getEndTime(),
28
            $report->isSuccessful(),
0 ignored issues
show
Bug introduced by
It seems like $report->isSuccessful() targeting Cron\Report\JobReport::isSuccessful() can also be of type null; however, T4web\Cron\Log\LoggerInterface::log() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
29
            $report->getOutput(),
30
            $report->getError()
31
        );
32
33
    }
34
}
35