EscolaLMS/model-fields

View on GitHub

Showing 192 of 192 total issues

Avoid using static access to class '\Spatie\Permission\Models\Permission' in method 'run'.
Open

            Permission::findOrCreate($permission, 'api');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\Illuminate\Support\Facades\Cache' in method 'getFieldsMetadata'.
Open

        $tableExist = Cache::rememberForever('model_fields_metadata_table_exists', function () {
            return Schema::hasTable('model_fields_metadata');
        });
Severity: Minor
Found in src/Services/ModelFieldsService.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\Illuminate\Support\Facades\Cache' in method 'getExtraAttributesValues'.
Open

            $modelFields = Cache::rememberForever($key, function () use ($model) {
                // @phpstan-ignore-next-line
                return $model->fields()->get();
            });
Severity: Minor
Found in src/Services/ModelFieldsService.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\EscolaLms\ModelFields\Facades\ModelFields' in method 'getExtraAttributesValues'.
Open

        return ModelFieldsFacade::getExtraAttributesValues($this);
Severity: Minor
Found in src/Traits/ModelFields.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\Spatie\Permission\Models\Role' in method 'run'.
Open

        $apiAdmin = Role::findOrCreate(UserRole::ADMIN, 'api');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Line exceeds 120 characters; contains 135 characters
Open

        return $bool ? $this->sendResponse(true, "meta field deleted successfully") : $this->sendError("meta field delete error", 404);

Line exceeds 120 characters; contains 193 characters
Open

    public function addOrUpdateMetadataField(string $class_type, string $name, string $type, string $default = '', array $rules = null, int $visibility = 1 << 0, array $extra = null): Metadata;

Line exceeds 120 characters; contains 121 characters
Open

    public static function firstOrCreate(array $attributes = [], array $values = []): \Illuminate\Database\Eloquent\Model
Severity: Minor
Found in src/Models/Model.php by phpcodesniffer

Line exceeds 120 characters; contains 137 characters
Open

            $this->extraFields = isset($this->extraFields) ? $this->extraFields->prepend(['name' => $key, 'value' => $value]) : collect([
Severity: Minor
Found in src/Models/Model.php by phpcodesniffer

Line exceeds 120 characters; contains 151 characters
Open

    public function getFieldsMetadataListPaginated(string $class_type, ?int $perPage = 15, ?OrderDto $orderDto = null): Collection|LengthAwarePaginator

Line exceeds 120 characters; contains 124 characters
Open

        return $this->sendResponseForResource(MetadataResource::make($field), "meta field created or updated successfully");

Line exceeds 120 characters; contains 131 characters
Open

        return $this->sendResponseForResource(MetadataResource::collection($metaFields), "metaFields list retrieved successfully");

Line exceeds 120 characters; contains 152 characters
Open

    public function getFieldsMetadataListPaginated(string $class_type, ?int $perPage = 15, ?OrderDto $orderDto = null): Collection|LengthAwarePaginator;

Line exceeds 120 characters; contains 192 characters
Open

    public function addOrUpdateMetadataField(string $class_type, string $name, string $type, string $default = '', array $rules = null, int $visibility = 1 << 0, array $extra = null): Metadata

Line exceeds 120 characters; contains 137 characters
Open

            $this->extraFields = isset($this->extraFields) ? $this->extraFields->prepend(['name' => $key, 'value' => $value]) : collect([
Severity: Minor
Found in src/Traits/ModelFields.php by phpcodesniffer

Line exceeds 120 characters; contains 135 characters
Open

        $metaFields = $this->service->getFieldsMetadataListPaginated($classType, $perPage, OrderDto::instantiateFromRequest($request));

Line exceeds 120 characters; contains 122 characters
Open

        $classTypes = class_parents($class_type) ? array_merge([$class_type], class_parents($class_type)) : [$class_type];

Line exceeds 120 characters; contains 131 characters
Open

        return $this->sendResponseForResource(MetadataResource::collection($metaFields), "metaFields list retrieved successfully");

Line exceeds 120 characters; contains 134 characters
Open

                ->mapWithKeys(fn($item, $key) => [$item['name'] => self::castField($item['value'], ($fields[$item['name']] ?? null))])

Line exceeds 120 characters; contains 134 characters
Open

                    $classTypes = class_parents($class_type) ? array_merge([$class_type], class_parents($class_type)) : [$class_type];
Severity
Category
Status
Source
Language