EventCollector::getSimplifiedEvents()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 3
1
<?php
2
3
namespace MS\Sentry\Monitor\Service\Import;
4
5
use MS\Sentry\Monitor\Model\SentryRequest;
6
use MS\Sentry\Monitor\Service\SentryClient;
7
8
class EventCollector
9
{
10
    const EVENTS_PATTERN = '/api/0/projects/%s/%s/events/';
11
12
    /**
13
     * @var SentryClient
14
     */
15
    private $sentryClient;
16
17
    /**
18
     * @param SentryClient $sentryClient
19
     */
20
    public function __construct(SentryClient $sentryClient)
21
    {
22
        $this->sentryClient = $sentryClient;
23
    }
24
25
    /**
26
     * @param SentryRequest $sentryRequest
27
     * @param string        $organisation
28
     * @param string        $project
29
     *
30
     * @return array
31
     */
32
    public function getSimplifiedEvents(SentryRequest $sentryRequest, $organisation, $project)
33
    {
34
        $events = $this
35
            ->sentryClient
36
            ->get($sentryRequest, sprintf(self::EVENTS_PATTERN, $organisation, $project));
37
38
        $result = [];
39
40
        foreach ($events as $event) {
41
            $result[] = [
42
                'id' => $event['id'],
43
                'created' => $event['dateCreated']
44
            ];
45
        }
46
47
        return $result;
48
    }
49
}
50