SentryClient::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 14
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 9
nc 1
nop 2
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