heximcz/mxtoolbox

View on GitHub
src/MxToolbox/NetworkTools/SmtpServerChecks.php

Summary

Maintainability
A
35 mins
Test Coverage

Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function __construct(NetworkTools $netTool, $addr, $myHostName, $mailFrom, $mailRcptTo)
Severity: Minor
Found in src/MxToolbox/NetworkTools/SmtpServerChecks.php - About 35 mins to fix

    Remove error control operator '@' on line 130.
    Open

        private function setSmtpConnect($addr)
        {
            $this->smtpConnection = @stream_socket_client($addr . ':' . $this->smtpPort, $errno, $errstr,
                $this->connTimeout, STREAM_CLIENT_CONNECT);
            if (is_resource($this->smtpConnection)) {

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Avoid unused local variables such as '$errno'.
    Open

            $this->smtpConnection = @stream_socket_client($addr . ':' . $this->smtpPort, $errno, $errstr,

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    Avoid unused local variables such as '$errstr'.
    Open

            $this->smtpConnection = @stream_socket_client($addr . ':' . $this->smtpPort, $errno, $errstr,

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    There are no issues that match your filters.

    Category
    Status