lib/Ajde/Component/Image.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method process has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function process()
    {
        switch ($this->_attributeParse()) {
            case 'base64':
                $image = new Ajde_Resource_Image($this->attributes['filename']);
Severity: Minor
Found in lib/Ajde/Component/Image.php - About 1 hr to fix

    Method getImageTag has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            $filename,
            $width = null,
            $height = null,
            $crop = true,
            $class = '',
    Severity: Major
    Found in lib/Ajde/Component/Image.php - About 50 mins to fix

      Missing class import via use statement (line '71', column '54').
      Open

              $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:image'));
      Severity: Minor
      Found in lib/Ajde/Component/Image.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 '25', column '30').
      Open

                      $image = new Ajde_Resource_Image($this->attributes['filename']);
      Severity: Minor
      Found in lib/Ajde/Component/Image.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 '30', column '62').
      Open

                      $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:imageBase64'));
      Severity: Minor
      Found in lib/Ajde/Component/Image.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 '66', column '22').
      Open

              $image = new Ajde_Resource_Image($filename);
      Severity: Minor
      Found in lib/Ajde/Component/Image.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

      The method getImageTag has a boolean flag argument $crop, which is a certain sign of a Single Responsibility Principle violation.
      Open

              $crop = true,
      Severity: Minor
      Found in lib/Ajde/Component/Image.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

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

      The method getImageTag has a boolean flag argument $lazy, which is a certain sign of a Single Responsibility Principle violation.
      Open

              $lazy = false,
      Severity: Minor
      Found in lib/Ajde/Component/Image.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

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

      The method getImageTag has a boolean flag argument $absoluteUrl, which is a certain sign of a Single Responsibility Principle violation.
      Open

              $absoluteUrl = false
      Severity: Minor
      Found in lib/Ajde/Component/Image.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

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

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

              throw new Ajde_Component_Exception('Missing required attributes for component call');
      Severity: Minor
      Found in lib/Ajde/Component/Image.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 'Ajde_Component_String' in method 'process'.
      Open

                      $image->setCrop(Ajde_Component_String::toBoolean(issetor($this->attributes['crop'], true)));
      Severity: Minor
      Found in lib/Ajde/Component/Image.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 'Ajde_Controller' in method 'getImageTag'.
      Open

              $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:image'));
      Severity: Minor
      Found in lib/Ajde/Component/Image.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 'Ajde_Component_String' in method 'process'.
      Open

                          Ajde_Component_String::toBoolean(issetor($this->attributes['crop'], true)),
      Severity: Minor
      Found in lib/Ajde/Component/Image.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 'Ajde_Controller' in method 'process'.
      Open

                      $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:imageBase64'));
      Severity: Minor
      Found in lib/Ajde/Component/Image.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

      TODO found
      Open

              // TODO:
      Severity: Minor
      Found in lib/Ajde/Component/Image.php by fixme

      The class Ajde_Component_Image is not named in CamelCase.
      Open

      class Ajde_Component_Image extends Ajde_Component
      {
          public static function processStatic(Ajde_Template_Parser $parser, $attributes)
          {
              $instance = new self($parser, $attributes);
      Severity: Minor
      Found in lib/Ajde/Component/Image.php by phpmd

      CamelCaseClassName

      Since: 0.2

      It is considered best practice to use the CamelCase notation to name classes.

      Example

      class class_name {
      }

      Source

      The method _init is not named in camelCase.
      Open

          protected function _init()
          {
              return [
                  'base64'   => 'base64',
                  'filename' => 'html',
      Severity: Minor
      Found in lib/Ajde/Component/Image.php by phpmd

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      There are no issues that match your filters.

      Category
      Status