src/Form/StanfordMigrateCsvImportForm.php
Method buildForm
has 56 lines of code (exceeds 40 allowed). Consider refactoring. Open
Open
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$migration_id = $this->entity->id();
$template_link = Link::fromTextAndUrl($this->t('empty CSV template'), $this->entity->toUrl('csv-template'))
->toString();
The class StanfordMigrateCsvImportForm has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13. Open
Open
class StanfordMigrateCsvImportForm extends EntityForm {
/**
* Migration plugin instance that matches the migration entity.
*
- 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
syntax error, unexpected 'protected' (T_PROTECTED), expecting variable (T_VARIABLE)
Invalid
Invalid
public function __construct(protected MigrationPluginManagerInterface $migrationManager, protected StateInterface $state, protected FileUsageInterface $fileUsage, EntityTypeManagerInterface $entityTypeManager) {
- Exclude checks
Avoid excessively long variable names like $previously_uploaded_files. Keep variable name length under 20. Wontfix
Wontfix
$previously_uploaded_files = $this->state->get("stanford_migrate.csv.$migration_id", []);
- 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
Doc comment short description must end with a full stop Invalid
Invalid
* {@inheritDoc}
- Exclude checks
Doc comment short description must start with a capital letter Invalid
Invalid
* {@inheritDoc}
- Exclude checks
Doc comment short description must start with a capital letter Invalid
Invalid
* {@inheritDoc}
- Exclude checks
Doc comment short description must end with a full stop Invalid
Invalid
* {@inheritDoc}
- Exclude checks
Doc comment short description must end with a full stop Invalid
Invalid
* {@inheritDoc}
- Exclude checks
Doc comment short description must start with a capital letter Invalid
Invalid
* {@inheritDoc}
- Exclude checks
Doc comment short description must end with a full stop Invalid
Invalid
* {@inheritDoc}
- Exclude checks
Doc comment short description must start with a capital letter Invalid
Invalid
* {@inheritDoc}
- Exclude checks