Skip to content

Commit

Permalink
Refactoring - Extract Socket Trait
Browse files Browse the repository at this point in the history
  • Loading branch information
svilborg committed Jul 16, 2019
1 parent 7b92263 commit 8a679ed
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 19 deletions.
6 changes: 5 additions & 1 deletion src/Checks/Network/Tcp.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
namespace Health\Checks\Network;

use Health\Checks\HealthCheckInterface;
use Health\Checks\BaseCheck;
use Health\Checks\Traits\SocketTrait;

class Tcp extends Socket implements HealthCheckInterface
class Tcp extends BaseCheck implements HealthCheckInterface
{

use SocketTrait;

/**
*
* {@inheritdoc}
Expand Down
5 changes: 4 additions & 1 deletion src/Checks/Network/Tcp6.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
namespace Health\Checks\Network;

use Health\Checks\HealthCheckInterface;
use Health\Checks\BaseCheck;
use Health\Checks\Traits\SocketTrait;

class Tcp6 extends Socket implements HealthCheckInterface
class Tcp6 extends BaseCheck implements HealthCheckInterface
{
use SocketTrait;

/**
*
Expand Down
5 changes: 4 additions & 1 deletion src/Checks/Network/Udp.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
namespace Health\Checks\Network;

use Health\Checks\HealthCheckInterface;
use Health\Checks\BaseCheck;
use Health\Checks\Traits\SocketTrait;

class Udp extends Socket implements HealthCheckInterface
class Udp extends BaseCheck implements HealthCheckInterface
{
use SocketTrait;

/**
*
Expand Down
5 changes: 4 additions & 1 deletion src/Checks/Network/Udp6.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
namespace Health\Checks\Network;

use Health\Checks\HealthCheckInterface;
use Health\Checks\BaseCheck;
use Health\Checks\Traits\SocketTrait;

class Udp6 extends Socket implements HealthCheckInterface
class Udp6 extends BaseCheck implements HealthCheckInterface
{
use SocketTrait;

/**
*
Expand Down
5 changes: 4 additions & 1 deletion src/Checks/Network/Unix.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
namespace Health\Checks\Network;

use Health\Checks\HealthCheckInterface;
use Health\Checks\BaseCheck;
use Health\Checks\Traits\SocketTrait;

class Unix extends Socket implements HealthCheckInterface
class Unix extends BaseCheck implements HealthCheckInterface
{
use SocketTrait;

/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
<?php
namespace Health\Checks\Network;
namespace Health\Checks\Traits;

use Health\Checks\BaseCheck;
use Health\Checks\HealthCheckInterface;

class Socket extends BaseCheck implements HealthCheckInterface
trait SocketTrait
{

protected $resource = null;

/**
* Socket resource
*
* {@inheritdoc}
* @see \Health\Checks\HealthCheckInterface::call()
* @var resource
*/
public function call()
{
return null;
}
protected $resource = null;

/**
*
* @param int $domain
* @param int $type
* @param int $protocol
*
* @return resource
*/
protected function create($domain, $type, $protocol)
{
Expand Down Expand Up @@ -61,7 +55,7 @@ protected function connect($address)
}

/**
* Close Socket
* Close SocketTrait
*/
protected function close()
{
Expand Down

0 comments on commit 8a679ed

Please sign in to comment.