ProductBuilder
has 22 functions (exceeds 20 allowed). Consider refactoring. Wontfix
class ProductBuilder
{
/**
* @var ProductRepositoryInterface
*/
File ProductBuilder.php
has 251 lines of code (exceeds 250 allowed). Consider refactoring. Wontfix
<?php
declare(strict_types=1);
namespace TddWizard\Fixtures\Catalog;
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);
Method __construct
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
ProductRepositoryInterface $productRepository,
StockItemRepositoryInterface $stockItemRepository,
ProductWebsiteLinkRepositoryInterface $websiteLinkRepository,
ProductWebsiteLinkInterfaceFactory $websiteLinkFactory,
IndexerFactory $indexerFactory,
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);
}
- Read upRead up
- Exclude checks
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);
}
- Read upRead up
- Exclude checks
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);
}
- Read upRead up
- Exclude checks
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);
}
- Read upRead up
- Exclude checks
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;
- Exclude checks
Avoid excessively long variable names like $websiteLinkRepository. Keep variable name length under 20. Open
private $websiteLinkRepository;
- Read upRead up
- Exclude checks
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,
- Read upRead up
- Exclude checks
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++ ) {
}
}
}