serbanghita/http-client

Similar code found in 1 other location

<?php
namespace HttpClientTest\Transport\Socks;

use HttpClient\Message\Request;
use \HttpClient\Transport\Socks;
Found in tests/lib/Transport/Socks/readTest.php and 1 other location - About 5 hrs to fix
tests/lib/Transport/Socks/readTest.php on lines 13..62

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Refactorings

Further Reading

Similar code found in 1 other location

<?php
namespace HttpClientTest\Transport\Socks;

use HttpClient\Message\Request;
use \HttpClient\Transport\Socks;
Found in tests/lib/Transport/Socks/readTest.php and 1 other location - About 5 hrs to fix
tests/lib/Transport/Socks/readTest.php on lines 68..111

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Refactorings

Further Reading

Complex method in read

    public function read()
    {
        // Defaults.
        $gotResponseHeaders = false;
        $responseHeaders = '';
Found in lib/Transport/Socks.php - About 2 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Method read is too long

    public function read()
    {
        // Defaults.
        $gotResponseHeaders = false;
        $responseHeaders = '';
Severity: Minor
Found in lib/Transport/Socks.php - About 1 hr to fix

Class AbstractTransport contains too many public methods

abstract class AbstractTransport implements TransportInterface
{
    protected $options = array();
    protected $host;
    protected $port = 80;
Severity: Minor
Found in lib/Transport/AbstractTransport.php - About 1 hr to fix

Cyclomatic complexity for function read is too high

    public function read()
    {
        // Defaults.
        $gotResponseHeaders = false;
        $responseHeaders = '';
Severity: Minor
Found in lib/Transport/Socks.php - About 1 hr to fix

Class AbstractMessage contains too many public methods

abstract class AbstractMessage implements MessageInterface
{
    protected $statusCode = 0;
    protected $httpVersion;
    /**
Severity: Minor
Found in lib/Message/AbstractMessage.php - About 40 mins to fix

Too many parameters in definition of function openStream

    protected function openStream($remote_socket, &$errno, &$errstr, $timeout, $flags)
Severity: Minor
Found in lib/Transport/Socks.php - About 30 mins to fix

Class AllMethodsTest contains too many public methods

class AllMethodsTest extends \PHPUnit_Framework_TestCase
{

    /**
     *  constructor sets the given input options
Severity: Minor
Found in tests/lib/Transport/AbstractTransport/allMethodsTest.php - About 30 mins to fix

Use of exit/die() detected

exit(json_encode($response));
Severity: Minor
Found in tests/providers/response/jsonrpc.php - About 30 mins to fix

Avoid accessing the superglobal $_GET directly

$page = isset($_GET['page']) ? $_GET['page'] : null;
Severity: Minor
Found in tests/providers/response/jsonrpc.php - About 10 mins to fix

Avoid accessing the superglobal $_GET directly

$page = isset($_GET['page']) ? $_GET['page'] : null;
Severity: Minor
Found in tests/providers/response/jsonrpc.php - About 10 mins to fix

The variable name, expectedHeadersString, is too long

        $expectedHeadersString = 'Host: test.mysite.local' . "\r\n" .
            'Connection: close' . "\r\n";
Severity: Minor
Found in tests/lib/Message/Headers/allMethodsTest.php - About 5 mins to fix

Remove call to debugging function var_dump

    var_dump($transport->getResponse()->getHeaders());
Severity: Minor
Found in tests/providers/test2.php - About 5 mins to fix

Remove call to debugging function var_dump

    var_dump($transport->getResponse()->getBody());
Severity: Minor
Found in tests/providers/test2.php - About 5 mins to fix

Remove call to debugging function var_dump

    var_dump($e->getCode());
Severity: Minor
Found in tests/providers/test2.php - About 5 mins to fix

Remove call to debugging function var_dump

    var_dump($e->getMessage());
Severity: Minor
Found in tests/providers/test2.php - About 5 mins to fix

Remove call to debugging function var_dump

    var_dump($e->getCode());
Severity: Minor
Found in tests/providers/test2.php - About 5 mins to fix

Remove call to debugging function var_dump

    var_dump($e->getMessage());
Severity: Minor
Found in tests/providers/test2.php - About 5 mins to fix

Do not change the error display levels at runtime

\error_reporting(E_ALL);
Severity: Minor
Found in tests/providers/test2.php - About 5 mins to fix