Curl::send()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.584
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * Communicator (https://github.com/waltertamboer/communicator)
4
 *
5
 * @link https://github.com/waltertamboer/communicator for the canonical source repository
6
 * @copyright Copyright (c) 2017 Communicator (https://github.com/waltertamboer/communicator)
7
 * @license https://github.com/waltertamboer/communicator/blob/master/LICENSE.md MIT
8
 */
9
10
namespace Communicator\Transport\Webhook\Adapter;
11
12
use Communicator\Transport\Webhook\SendData;
13
14
/**
15
 * A curl adapter.
16
 */
17
final class Curl implements AdapterInterface
18
{
19
    /**
20
     * Sends a message over the transport.
21
     *
22
     * @param SendData $data The data that should be send in the request.
23
     * @return bool Returns true when the call succeeded; false otherwise.
24
     */
25
    public function send(SendData $data): bool
26
    {
27
        // @codeCoverageIgnoreStart
28
29
        $ch = curl_init();
30
31
        curl_setopt($ch, CURLOPT_URL, "example.com");
32
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
33
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
34
35
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
36
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
37
38
        $output = curl_exec($ch);
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
39
40
        curl_close($ch);
41
42
        // @codeCoverageIgnoreEnd
43
44
        return true;
45
    }
46
}
47