badgeteam/Hatchery

View on GitHub
app/Http/Controllers/MchController.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method app has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function app(string $device, string $type, string $category, string $app): JsonResponse
    {
        /** @var Badge $badge */
        $badge = Badge::whereSlug($device)->firstOrFail();
        $categoryId = Category::whereSlug($category)->firstOrFail()->id;
Severity: Minor
Found in app/Http/Controllers/MchController.php - About 1 hr to fix

    Method file has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            string $device,
            string $type,
            string $category,
            string $app,
            string $name
    Severity: Minor
    Found in app/Http/Controllers/MchController.php - About 35 mins to fix

      Missing class import via use statement (line '227', column '29').
      Open

                  $fileData = new \stdClass();

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Avoid using static access to class '\App\Models\Category' in method 'categories'.
      Open

                  $category = Category::find($id);

      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 '\App\Models\Badge' in method 'devices'.
      Open

              foreach (Badge::pluck('name', 'slug') as $slug => $name) {

      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 142 characters
      Open

              foreach ($badge->projects()->whereNotNull('published_at')->whereProjectType($type)->whereCategoryId($categoryId)->get() as $project) {

      There are no issues that match your filters.

      Category
      Status