nilsabegg/sesame

View on GitHub
src/Sesame/Crawler/ArticleCrawler.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid unused parameters such as '$crawlVariations'.
Open

    public function crawlArticle(string $responseBody, bool $crawlVariations): Article
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractDescription(DomCrawler $articleCrawler): string
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $descriptionHtml = $articleCrawler->filter('#j-product-description');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractPrice(DomCrawler $articleCrawler): float
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractPriceDiscount(DomCrawler $articleCrawler): float
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $nameHtml = $articleCrawler->filter('h1.product-name');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $sellerHtml = $articleCrawler->filter('#j-store-info-wrap .store-lnk');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $priceCurrencyHtml = $articleCrawler->filter('.p-price-content .p-symbol');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractRatingAmount(DomCrawler $articleCrawler): int
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractSeller(DomCrawler $articleCrawler): string
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $priceHtml = $articleCrawler->filter('#j-sku-price');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractSellerSince(DomCrawler $articleCrawler): int
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractStock(DomCrawler $articleCrawler): int
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $propertyElements = $articleCrawler->filter('.product-property-list .property-item');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Argument 1 (rating) is float but \Sesame\Model\Article::setRating() takes int defined at /code/src/Sesame/Model/Article.php:231
Open

        $article->setRating($this->extractRating($articleCrawler));
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractRating(DomCrawler $articleCrawler): float
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $priceDiscountHtml = $articleCrawler->filter('#j-sku-discount-price');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $sellerSinceHtml = $articleCrawler->filter('.store-open-time span');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

            $propertyTitle = substr($propertyCrawler->filter('.propery-title')->text(), 0, -1);
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractOrders(DomCrawler $articleCrawler): int
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method __construct from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $articleCrawler = new DomCrawler($responseBody);
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $sellerFeedbackHtml = $articleCrawler->filter('.seller-score-feedback span a');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $ratingHtml = $articleCrawler->filter('#j-customer-reviews-trigger .percent-num');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractSellerFeedback(DomCrawler $articleCrawler): float
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $sellerLocationHtml = $articleCrawler->filter('#j-store-info-wrap .store-address');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractPriceCurrency(DomCrawler $articleCrawler): string
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $stockAmountHtml = $articleCrawler->filter('#j-sell-stock-num');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractProperties(DomCrawler $articleCrawler): array
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractSellerLocation(DomCrawler $articleCrawler): string
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $ordersHtml = $articleCrawler->filter('#j-order-num');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method __construct from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

            $propertyCrawler = new DomCrawler($propertyElement);
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

            $propertyValue = $propertyCrawler->filter('.propery-des')->text();
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $ratingAmountHtml = $articleCrawler->filter('#j-customer-reviews-trigger .rantings-num');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

The method extractProperties uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $properties[$propertyTitle] = $propertyValue;
            }
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Remove this commented out code.
Open

        //$article->setSellerFeedback($this->extractSellerFeedback($articleCrawler));

Programmers should not comment out code as it bloats programs and reduces readability.

Unused code should be deleted and can be retrieved from source control history if required.

See

  • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
  • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
  • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
  • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

Avoid excessively long variable names like $ratingAmountStringParts. Keep variable name length under 20.
Open

        $ratingAmountStringParts = explode(' ', $ratingAmountString);
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $stockAmountStringParts. Keep variable name length under 20.
Open

        $stockAmountStringParts = explode(' ', $stockAmountString);
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $sellerSinceStringParts. Keep variable name length under 20.
Open

        $sellerSinceStringParts = explode(' ', $sellerSinceString);
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

There are no issues that match your filters.

Category
Status