Sender::send()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
3
namespace Alawar\NginxPushStreamBundle\Http;
4
5
use Guzzle\Http\Client;
6
use Guzzle\Http\ClientInterface;
7
8
class Sender implements SenderInterface
9
{
10
    /**
11
     * @var \Guzzle\Http\Client|null
12
     */
13
    protected $client = null;
14
15
    public function __construct()
16
    {
17
        $this->client = new Client();
18
    }
19
20
    /**
21
     * @param ClientInterface $client
22
     */
23
    public function setClient(ClientInterface $client)
24
    {
25
        $this->client = $client;
0 ignored issues
show
Documentation Bug introduced by
It seems like $client of type object<Guzzle\Http\ClientInterface> is incompatible with the declared type object<Guzzle\Http\Client>|null of property $client.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
26
    }
27
28
    /**
29
     * @param string $url
30
     * @param string $body
31
     * @param string[] $headers
32
     * @return bool
33
     */
34
    public function send($url, $body, $headers)
35
    {
36
        $request = $this->client->post($url, $headers, $body);
37
        $response = $request->send();
38
        return $response->isSuccessful();
39
    }
40
}
41