SentryClient   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 36
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 14 1
1
<?php
2
3
namespace MS\Sentry\Monitor\Service;
4
5
use MS\Sentry\Monitor\Model\SentryRequest;
6
use GuzzleHttp\Client;
7
8
class SentryClient
9
{
10
    /**
11
     * @var Client
12
     */
13
    private $client;
14
15
    /**
16
     * @param Client $client
17
     */
18
    public function __construct(Client $client)
19
    {
20
        $this->client = $client;
21
    }
22
23
    /**
24
     * @param SentryRequest $sentryRequest
25
     * @param string        $endpoint
26
     *
27
     * @return array
28
     */
29
    public function get(SentryRequest $sentryRequest, $endpoint)
30
    {
31
        $stream = $this
32
            ->client
33
            ->get($sentryRequest->getBaseUrl() . $endpoint, [
34
                'headers' =>  [
35
                    'Authorization' => sprintf('Bearer %s', $sentryRequest->getApiKey())
36
                ]
37
            ])
38
            ->getBody()
39
            ->getContents();
40
41
        return json_decode($stream, true);
42
    }
43
}
44