denpamusic/php-levin

View on GitHub
src/Exceptions/ConnectionException.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

declare(strict_types=1);

namespace Denpa\Levin\Exceptions;

use Exception;

class ConnectionException extends Exception
{
    /**
     * @param resource $socket
     * @param mixed    $args,...
     *
     * @return void
     */
    public function __construct($socket, ...$args)
    {
        $errno = socket_last_error($socket);
        parent::__construct(socket_strerror($errno), $errno, ...$args);

        socket_clear_error($socket);
    }
}