tddwizard/magento2-fixtures

View on GitHub
src/Catalog/ProductBuilder.php

Summary

Maintainability
A
2 hrs
Test Coverage

ProductBuilder has 22 functions (exceeds 20 allowed). Consider refactoring.
Wontfix

class ProductBuilder
{
    /**
     * @var ProductRepositoryInterface
     */
Severity: Minor
Found in src/Catalog/ProductBuilder.php - About 2 hrs to fix

    File ProductBuilder.php has 251 lines of code (exceeds 250 allowed). Consider refactoring.
    Wontfix

    <?php
    declare(strict_types=1);
    
    namespace TddWizard\Fixtures\Catalog;
    
    
    Severity: Minor
    Found in src/Catalog/ProductBuilder.php - About 2 hrs to fix

      Method aSimpleProduct has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function aSimpleProduct(): ProductBuilder
          {
              $objectManager = Bootstrap::getObjectManager();
              /** @var Product $product */
              $product = $objectManager->create(ProductInterface::class);
      Severity: Minor
      Found in src/Catalog/ProductBuilder.php - About 1 hr to fix

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

                ProductRepositoryInterface $productRepository,
                StockItemRepositoryInterface $stockItemRepository,
                ProductWebsiteLinkRepositoryInterface $websiteLinkRepository,
                ProductWebsiteLinkInterfaceFactory $websiteLinkFactory,
                IndexerFactory $indexerFactory,
        Severity: Major
        Found in src/Catalog/ProductBuilder.php - About 1 hr to fix

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

                  } else {
                      $builder->product->setStatus($status);
                  }
          Severity: Minor
          Found in src/Catalog/ProductBuilder.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

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

                  } else {
                      $builder->product->setName($name);
                  }
          Severity: Minor
          Found in src/Catalog/ProductBuilder.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

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

                      } else {
                          $builder->product->setCustomAttribute($code, $value);
                      }
          Severity: Minor
          Found in src/Catalog/ProductBuilder.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

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

                  } else {
                      $builder->product->setVisibility($visibility);
                  }
          Severity: Minor
          Found in src/Catalog/ProductBuilder.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

          Returning type \Magento\Catalog\Model\Product but buildWithoutSave() is declared to return \Magento\Catalog\Api\Data\ProductInterface
          Confirmed

                  return clone $this->product;
          Severity: Minor
          Found in src/Catalog/ProductBuilder.php by phan

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

              private $websiteLinkRepository;
          Severity: Minor
          Found in src/Catalog/ProductBuilder.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 $websiteLinkRepository. Keep variable name length under 20.
          Open

                  ProductWebsiteLinkRepositoryInterface $websiteLinkRepository,
          Severity: Minor
          Found in src/Catalog/ProductBuilder.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