Socket   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A remotePointer() 0 11 2
1
<?php
2
3
namespace kalanis\RemoteRequest\Sockets;
4
5
6
use kalanis\RemoteRequest\Interfaces\IConnectionParams;
7
use kalanis\RemoteRequest\RequestException;
8
9
10
/**
11
 * Class Socket
12
 * @package kalanis\RemoteRequest\Sockets
13
 * Network pointer to the remote server - method Socket
14
 * This one needs own processor - cannot write here via fwrite(), must use socket_sendto()!
15
 */
16
class Socket extends ASocket
17
{
18
    /**
19
     * @param IConnectionParams $params
20
     * @throws RequestException
21
     * @return resource
22
     * @codeCoverageIgnore because accessing remote source via internal socket
23
     */
24
    protected function remotePointer(IConnectionParams $params)
25
    {
26
        // Make the request to the server
27
        // If possible, securely post using HTTPS, your PHP server will need to be SSL enabled
28
        if (!$filePointer = socket_create(AF_INET, SOCK_DGRAM, $params->getProtocolVersion())) {
29
            $errorCode = socket_last_error();
30
            $errorMessage = socket_strerror($errorCode);
31
32
            throw new RequestException($this->getRRLang()->rrSocketCannotConnect2($errorMessage), $errorCode);
33
        }
34
        return $filePointer;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $filePointer also could return the type Socket which is incompatible with the documented return type resource.
Loading history...
35
    }
36
}
37