seregazhuk/php-pinterest-bot

View on GitHub
src/Api/Request.php

Summary

Maintainability
A
2 hrs
Test Coverage

Request has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

class Request
{
    const DEFAULT_TOKEN = '1234';

    /**
Severity: Minor
Found in src/Api/Request.php - About 2 hrs to fix

    Missing class import via use statement (line '232', column '32').
    Open

            $data['context'] = new \stdClass();
    Severity: Minor
    Found in src/Api/Request.php by phpmd

    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

    Missing class import via use statement (line '229', column '39').
    Open

                $data = ['options' => new \stdClass()];
    Severity: Minor
    Found in src/Api/Request.php by phpmd

    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 assigning values to variables in if clauses and the like (line '247', column '13').
    Open

        protected function setTokenFromCookies()
        {
            if ($token = $this->httpClient->cookie('csrftoken')) {
                $this->csrfToken = $token;
            }
    Severity: Minor
    Found in src/Api/Request.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

    Avoid using static access to class '\seregazhuk\PinterestBot\Helpers\UrlBuilder' in method 'createQuery'.
    Open

            return UrlBuilder::buildRequestString($request);
    Severity: Minor
    Found in src/Api/Request.php by phpmd

    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 '\seregazhuk\PinterestBot\Helpers\FileHelper' in method 'buildFilePostData'.
    Open

            $data .= 'Content-Type: ' . FileHelper::getMimeType($this->filePathToUpload) . "\r\n\r\n";
    Severity: Minor
    Found in src/Api/Request.php by phpmd

    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 '\seregazhuk\PinterestBot\Helpers\UrlBuilder' in method 'exec'.
    Open

            $url = UrlBuilder::buildApiUrl($resourceUrl);
    Severity: Minor
    Found in src/Api/Request.php by phpmd

    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

    Line exceeds 120 characters; contains 125 characters
    Open

            $data .= 'Content-Disposition: form-data; name="img"; filename="' . basename($this->filePathToUpload) . '"' . "\r\n";
    Severity: Minor
    Found in src/Api/Request.php by phpcodesniffer

    Line indented incorrectly; expected at least 4 spaces, found 0
    Open

    ];
    Severity: Minor
    Found in src/Api/Request.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status