rinvex/laravel-attributes

View on GitHub

Showing 27 of 27 total issues

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php
 
declare(strict_types=1);
 
use Illuminate\Support\Facades\Schema;
database/migrations/2020_01_01_000002_create_attribute_text_values_table.php on lines 1..42
database/migrations/2020_01_01_000003_create_attribute_boolean_values_table.php on lines 1..42
database/migrations/2020_01_01_000004_create_attribute_datetime_values_table.php on lines 1..42
database/migrations/2020_01_01_000005_create_attribute_integer_values_table.php on lines 1..42

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php
 
declare(strict_types=1);
 
use Illuminate\Support\Facades\Schema;
database/migrations/2020_01_01_000003_create_attribute_boolean_values_table.php on lines 1..42
database/migrations/2020_01_01_000004_create_attribute_datetime_values_table.php on lines 1..42
database/migrations/2020_01_01_000005_create_attribute_integer_values_table.php on lines 1..42
database/migrations/2020_01_01_000006_create_attribute_varchar_values_table.php on lines 1..42

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php
 
declare(strict_types=1);
 
use Illuminate\Support\Facades\Schema;
database/migrations/2020_01_01_000002_create_attribute_text_values_table.php on lines 1..42
database/migrations/2020_01_01_000003_create_attribute_boolean_values_table.php on lines 1..42
database/migrations/2020_01_01_000004_create_attribute_datetime_values_table.php on lines 1..42
database/migrations/2020_01_01_000006_create_attribute_varchar_values_table.php on lines 1..42

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php
 
declare(strict_types=1);
 
use Illuminate\Support\Facades\Schema;
database/migrations/2020_01_01_000002_create_attribute_text_values_table.php on lines 1..42
database/migrations/2020_01_01_000003_create_attribute_boolean_values_table.php on lines 1..42
database/migrations/2020_01_01_000005_create_attribute_integer_values_table.php on lines 1..42
database/migrations/2020_01_01_000006_create_attribute_varchar_values_table.php on lines 1..42

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php
 
declare(strict_types=1);
 
use Illuminate\Support\Facades\Schema;
database/migrations/2020_01_01_000002_create_attribute_text_values_table.php on lines 1..42
database/migrations/2020_01_01_000004_create_attribute_datetime_values_table.php on lines 1..42
database/migrations/2020_01_01_000005_create_attribute_integer_values_table.php on lines 1..42
database/migrations/2020_01_01_000006_create_attribute_varchar_values_table.php on lines 1..42

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php
 
declare(strict_types=1);
 
namespace Rinvex\Attributes\Models\Type;
Severity: Major
Found in src/Models/Type/Integer.php and 4 other locations - About 2 hrs to fix
src/Models/Type/Boolean.php on lines 1..60
src/Models/Type/Datetime.php on lines 1..60
src/Models/Type/Text.php on lines 1..60
src/Models/Type/Varchar.php on lines 1..60

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php
 
declare(strict_types=1);
 
namespace Rinvex\Attributes\Models\Type;
Severity: Major
Found in src/Models/Type/Datetime.php and 4 other locations - About 2 hrs to fix
src/Models/Type/Boolean.php on lines 1..60
src/Models/Type/Integer.php on lines 1..60
src/Models/Type/Text.php on lines 1..60
src/Models/Type/Varchar.php on lines 1..60

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php
 
declare(strict_types=1);
 
namespace Rinvex\Attributes\Models\Type;
Severity: Major
Found in src/Models/Type/Varchar.php and 4 other locations - About 2 hrs to fix
src/Models/Type/Boolean.php on lines 1..60
src/Models/Type/Datetime.php on lines 1..60
src/Models/Type/Integer.php on lines 1..60
src/Models/Type/Text.php on lines 1..60

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php
 
declare(strict_types=1);
 
namespace Rinvex\Attributes\Models\Type;
Severity: Major
Found in src/Models/Type/Text.php and 4 other locations - About 2 hrs to fix
src/Models/Type/Boolean.php on lines 1..60
src/Models/Type/Datetime.php on lines 1..60
src/Models/Type/Integer.php on lines 1..60
src/Models/Type/Varchar.php on lines 1..60

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php
 
declare(strict_types=1);
 
namespace Rinvex\Attributes\Models\Type;
Severity: Major
Found in src/Models/Type/Boolean.php and 4 other locations - About 2 hrs to fix
src/Models/Type/Datetime.php on lines 1..60
src/Models/Type/Integer.php on lines 1..60
src/Models/Type/Text.php on lines 1..60
src/Models/Type/Varchar.php on lines 1..60

File Attributable.php has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
 
declare(strict_types=1);
 
namespace Rinvex\Attributes\Traits;
Severity: Minor
Found in src/Traits/Attributable.php - About 2 hrs to fix

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

protected $throwValidationExceptions = true;
Severity: Minor
Found in src/Models/Attribute.php by phpmd

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

protected $throwValidationExceptions = true;
Severity: Minor
Found in src/Models/Value.php by phpmd

Function handle has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

public function handle(Entity $entity): void
{
$this->trash = $entity->getEntityAttributeValueTrash();
 
// Wrap the whole process inside database transaction
Severity: Minor
Found in src/Events/EntityWasSaved.php - About 1 hr to fix

Method handle has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public function handle(Entity $entity): void
{
$this->trash = $entity->getEntityAttributeValueTrash();
 
// Wrap the whole process inside database transaction
Severity: Minor
Found in src/Events/EntityWasSaved.php - About 1 hr to fix

Function __wakeup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

public function __wakeup()
{
parent::__wakeup();
 
if ($this->entityAttributeRelations && is_string(current($this->entityAttributeRelations))) {
Severity: Minor
Found in src/Traits/Attributable.php - About 35 mins to fix

Function __sleep has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

public function __sleep()
{
if ($this->entityAttributeRelations && current($this->entityAttributeRelations) instanceof Closure) {
$relations = $this->entityAttributeRelations;
$this->entityAttributeRelations = [];
Severity: Minor
Found in src/Traits/Attributable.php - About 35 mins to fix

Function handle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

public function handle(Entity $entity): void
{
// We will initially check if the model is using soft deletes. If so,
// the attribute values will remain untouched as they should sill
// be available till the entity is truly deleted from database.
Severity: Minor
Found in src/Events/EntityWasDeleted.php - About 25 mins to fix

Avoid assigning values to variables in if clauses and the like (line '132', column '21').
Open

public function relationsToArray()
{
$eavAttributes = [];
$attributes = parent::relationsToArray();
$relations = array_keys($this->getEntityAttributeRelations());
Severity: Minor
Found in src/Traits/Attributable.php by phpmd

Avoid unused parameters such as '$model'.
Open

static::saved(function ($model) use ($entities) {
Severity: Minor
Found in src/Models/Attribute.php by phpmd
Severity
Category
Status
Source
Language