Tcp   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A call() 0 15 2
1
<?php
2
namespace Health\Checks\Network;
3
4
use Health\Checks\HealthCheckInterface;
5
use Health\Checks\BaseCheck;
6
use Health\Checks\Traits\SocketTrait;
7
8
class Tcp extends BaseCheck implements HealthCheckInterface
9
{
10
11
    use SocketTrait;
12
13
    /**
14
     *
15
     * {@inheritdoc}
16
     * @see \Health\Checks\HealthCheckInterface::call()
17
     */
18
    public function call()
19
    {
20
        $builder = $this->getBuilder();
21
22
        $address = $this->getParam('address', '');
23
24
        $this->create(AF_INET, SOCK_STREAM, SOL_TCP);
25
26
        if (! $this->connect($address)) {
27
            $builder->down()->withData('error', $this->getError());
28
        }
29
30
        $this->close();
31
32
        return $builder->build();
33
    }
34
}
35