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

MessageDataCollector::reset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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