File ApiClient.php
has 303 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Opteck;
use GuzzleHttp;
Method openPosition
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function openPosition($email, $password, $symbol, $direction, $amount)
The class ApiClient has a coupling between objects value of 33. Consider to reduce the number of dependencies under 13. Open
class ApiClient implements LoggerAwareInterface
{
/**
* @var \GuzzleHttp\ClientInterface A Guzzle HTTP client.
*/
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Missing class import via use statement (line '487', column '23'). Open
throw new \Exception($e->getResponse()->getReasonPhrase(), $e->getResponse()->getStatusCode());
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class '\GuzzleHttp\HandlerStack' in method 'getHttpClient'. Open
$stack = GuzzleHttp\HandlerStack::create();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\GuzzleHttp\Middleware' in method 'getHttpClient'. Open
$stack->push(GuzzleHttp\Middleware::log(
$this->logger,
new GuzzleHttp\MessageFormatter(GuzzleHttp\MessageFormatter::DEBUG)
));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}