Passed
Push — master ( 5c935d...fdde8f )
by Mihai
03:31
created

MessageDataCollector   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getPublishedMessagesCount() 0 3 1
A collect() 0 5 3
A __construct() 0 4 1
A getPublishedMessagesLog() 0 3 1
A getName() 0 3 1
A reset() 0 3 1
1
<?php
2
3
namespace OldSound\RabbitMqBundle\DataCollector;
4
5
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpKe...Collector\DataCollector was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Symfony\Component\HttpFoundation\Request;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Symfony\Component\HttpFoundation\Response;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\Response was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
/**
10
 * MessageDataCollector
11
 *
12
 * @author Marc Weistroff <[email protected]>
13
 */
14
class MessageDataCollector extends DataCollector
15
{
16
    private $channels;
17
18
    public function __construct($channels)
19
    {
20
        $this->channels = $channels;
21
        $this->data = array();
0 ignored issues
show
Bug Best Practice introduced by
The property data does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
22
    }
23
24
    public function collect(Request $request, Response $response, \Throwable $exception = null)
25
    {
26
        foreach ($this->channels as $channel) {
27
            foreach ($channel->getBasicPublishLog() as $log) {
28
                $this->data[] = $log;
0 ignored issues
show
Bug Best Practice introduced by
The property data does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
29
            }
30
        }
31
    }
32
33
    public function getName()
34
    {
35
        return 'rabbit_mq';
36
    }
37
38
    public function getPublishedMessagesCount()
39
    {
40
        return count($this->data);
41
    }
42
43
    public function getPublishedMessagesLog()
44
    {
45
        return $this->data;
46
    }
47
48
    public function reset()
49
    {
50
        $this->data = [];
0 ignored issues
show
Bug Best Practice introduced by
The property data does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
51
    }
52
}
53