Sender   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setClient() 0 4 1
A send() 0 6 1
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