GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

QueuedJobHandler   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 4
dl 0
loc 55
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getJob() 0 4 1
A getJobDescriptor() 0 4 1
A write() 0 4 1
A handleBatch() 0 9 2
1
<?php
2
3
namespace Symbiote\QueuedJobs\Services;
4
5
use Monolog\Handler\AbstractProcessingHandler;
6
use SilverStripe\Core\Injector\Injectable;
7
use Symbiote\QueuedJobs\DataObjects\QueuedJobDescriptor;
8
9
/**
10
 * Writes log output to a job descriptor
11
 */
12
class QueuedJobHandler extends AbstractProcessingHandler
13
{
14
    use Injectable;
15
16
    /** @var QueuedJob */
17
    protected $job;
18
19
    /** @var QueuedJobDescriptor */
20
    protected $jobDescriptor;
21
22
    public function __construct(QueuedJob $job, QueuedJobDescriptor $jobDescriptor)
23
    {
24
        parent::__construct();
25
26
        $this->job = $job;
27
        $this->jobDescriptor = $jobDescriptor;
28
    }
29
30
    /**
31
     * @return QueuedJob
32
     */
33
    public function getJob()
34
    {
35
        return $this->job;
36
    }
37
38
    /**
39
     * @return QueuedJobDescriptor
40
     */
41
    public function getJobDescriptor()
42
    {
43
        return $this->jobDescriptor;
44
    }
45
46
    /**
47
     * Writes the record down to the log of the implementing handler
48
     *
49
     * @param  array $record
50
     * @return void
51
     */
52
    protected function write(array $record)
53
    {
54
        $this->handleBatch([$record]);
55
    }
56
57
    public function handleBatch(array $records)
58
    {
59
        foreach ($records as $record) {
60
            $this->job->addMessage($record['message'], $record['level_name'], $record['datetime']);
0 ignored issues
show
Unused Code introduced by
The call to QueuedJob::addMessage() has too many arguments starting with $record['level_name'].

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
61
        };
62
        $this->jobDescriptor->SavedJobMessages = serialize($this->job->getJobData()->messages);
63
64
        $this->jobDescriptor->write();
65
    }
66
}
67