brandon14/brand0n.gg

View on GitHub
app/Listeners/GenerateFavicons.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method createThumbnail has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function createThumbnail($import, $export, $width, $height, $background, $border)
    {
        $svg           = file_get_contents($import);
        $svgObj        = simplexml_load_string($svg);
        $viewBox       = explode(' ', $svgObj['viewBox']);
Severity: Minor
Found in app/Listeners/GenerateFavicons.php - About 1 hr to fix

    Method createThumbnail has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        private function createThumbnail($import, $export, $width, $height, $background, $border)
    Severity: Minor
    Found in app/Listeners/GenerateFavicons.php - About 45 mins to fix

      Missing class import via use statement (line '65', column '37').
      Open

              $im->setBackgroundColor(new \ImagickPixel($background));
      Severity: Minor
      Found in app/Listeners/GenerateFavicons.php by phpmd

      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

      Missing class import via use statement (line '63', column '19').
      Open

              $im = new \Imagick();
      Severity: Minor
      Found in app/Listeners/GenerateFavicons.php by phpmd

      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 '\Illuminate\Support\Facades\Artisan' in method 'handle'.
      Open

              Artisan::call('cache:clear');
      Severity: Minor
      Found in app/Listeners/GenerateFavicons.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

      The method createThumbnail uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $ratio = $height / $viewBoxHeight;
              }
      Severity: Minor
      Found in app/Listeners/GenerateFavicons.php by phpmd

      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 createThumbnail uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $compensateWidth = $width - ($viewBoxWidth * $ratio);
                  $im->extentImage($width - $compensateWidth / 2, $height, $compensateWidth * -.5, 0);
                  $im->extentImage($width, $height, 0, 0);
              }
      Severity: Minor
      Found in app/Listeners/GenerateFavicons.php by phpmd

      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

      Call to method extentImage from undeclared class \Imagick
      Open

                  $im->extentImage($width, $height - $compensateHeight / 2, 0, $compensateHeight * -.5);
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method extentImage from undeclared class \Imagick
      Open

                  $im->extentImage($width - $compensateWidth / 2, $height, $compensateWidth * -.5, 0);
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method call from undeclared class \Illuminate\Support\Facades\Artisan
      Open

              Artisan::call('cache:clear');
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method __construct from undeclared class \ImagickPixel
      Open

              $im->setBackgroundColor(new \ImagickPixel($background));
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method inDefaultSite from undeclared class \Statamic\Globals\GlobalSet
      Open

                     && $globals->inDefaultSite()->get('use');
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method readImageBlob from undeclared class \Imagick
      Open

              $im->readImageBlob($svg);
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method getImageBlob from undeclared class \Imagick
      Open

              file_put_contents($export, $im->getImageBlob());
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Parameter $globals has undeclared type \Statamic\Globals\GlobalSet
      Open

          private function shouldHandle(GlobalSet $globals)
      Severity: Minor
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method setBackgroundColor from undeclared class \Imagick
      Open

              $im->setBackgroundColor(new \ImagickPixel($background));
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Reference to constant FILTER_LANCZOS from undeclared class \Imagick
      Open

                  $im->resizeImage($width, $height, \imagick::FILTER_LANCZOS, 1);
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method handle from undeclared class \Statamic\Globals\GlobalSet
      Open

              return $globals->handle() === 'favicons'
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Parameter $event has undeclared type \Statamic\Events\GlobalSetSaved
      Open

          public function handle(GlobalSetSaved $event)
      Severity: Minor
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method __construct from undeclared class \Imagick
      Open

              $im = new \Imagick();
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method setResolution from undeclared class \Imagick
      Open

              $im->setResolution($viewBoxWidth * $ratio * 2, $viewBoxHeight * $ratio * 2);
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method extentImage from undeclared class \Imagick
      Open

                  $im->extentImage($width, $height, 0, 0);
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method extentImage from undeclared class \Imagick
      Open

                  $im->extentImage($width, $height, 0, 0);
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method resizeImage from undeclared class \Imagick
      Open

                  $im->resizeImage($width, $height, \imagick::FILTER_LANCZOS, 1);
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method destroy from undeclared class \Imagick
      Open

              $im->destroy();
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method setImageFormat from undeclared class \Imagick
      Open

              $im->setImageFormat('png32');
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Reference to instance property globals from undeclared class \Statamic\Events\GlobalSetSaved
      Open

              $globals = $event->globals;
      Severity: Minor
      Found in app/Listeners/GenerateFavicons.php by phan

      Suspicious array access to \SimpleXMLElement|false
      Open

              $viewBox       = explode(' ', $svgObj['viewBox']);
      Severity: Minor
      Found in app/Listeners/GenerateFavicons.php by phan

      Reference to constant FILTER_LANCZOS from undeclared class \Imagick
      Open

              $im->resizeImage($viewBoxWidth * $ratio, $viewBoxHeight * $ratio, \imagick::FILTER_LANCZOS, 1);
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method resizeImage from undeclared class \Imagick
      Open

              $im->resizeImage($viewBoxWidth * $ratio, $viewBoxHeight * $ratio, \imagick::FILTER_LANCZOS, 1);
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method clear from undeclared class \Imagick
      Open

              $im->clear();
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Call to method borderImage from undeclared class \Imagick
      Open

                  $im->borderImage($background, $border, $border);
      Severity: Critical
      Found in app/Listeners/GenerateFavicons.php by phan

      Avoid variables with short names like $im. Configured minimum length is 3.
      Open

              $im = new \Imagick();
      Severity: Minor
      Found in app/Listeners/GenerateFavicons.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      Opening brace indented incorrectly; expected 4 spaces, found 11
      Open

          : bool {

      Only one argument is allowed per line in a multi-line function call
      Open

              $this->createThumbnail('favicons/' . $svg, 'favicons/android-chrome-512x512.png', 512, 512, 'transparent',

      Only one argument is allowed per line in a multi-line function call
      Open

              $this->createThumbnail('favicons/' . $svg, 'favicons/android-chrome-512x512.png', 512, 512, 'transparent',

      Only one argument is allowed per line in a multi-line function call
      Open

              $this->createThumbnail('favicons/' . $svg, 'favicons/android-chrome-512x512.png', 512, 512, 'transparent',

      Only one argument is allowed per line in a multi-line function call
      Open

              $this->createThumbnail('favicons/' . $svg, 'favicons/android-chrome-512x512.png', 512, 512, 'transparent',

      Closing parenthesis of a multi-line function call must be on a line by itself
      Open

                  false);

      Opening parenthesis of a multi-line function call must be the last content on the line
      Open

              $this->createThumbnail('favicons/' . $svg, 'favicons/android-chrome-512x512.png', 512, 512, 'transparent',

      Multi-line function call not indented correctly; expected 8 spaces but found 12
      Open

                  false);

      There are no issues that match your filters.

      Category
      Status