RebelCode/rcmod-eddbk-rest-api

View on GitHub
src/Controller/BookingsController.php

Summary

Maintainability
D
1 day
Test Coverage

File BookingsController.php has 381 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace RebelCode\EddBookings\RestApi\Controller;

use Dhii\Data\Container\ContainerSetCapableTrait;
Severity: Minor
Found in src/Controller/BookingsController.php - About 5 hrs to fix

    Method _getUpdateParamFieldMapping has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function _getUpdateParamFieldMapping()
        {
            return [
                'start'    => [
                    'field'     => 'start',
    Severity: Major
    Found in src/Controller/BookingsController.php - About 2 hrs to fix

      Method _getSelectConditionParamMapping has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function _getSelectConditionParamMapping()
          {
              return [
                  'id'       => [
                      'compare' => 'eq',
      Severity: Minor
      Found in src/Controller/BookingsController.php - About 1 hr to fix

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

            protected function _getInsertParamFieldMapping()
            {
                return [
                    'start'    => [
                        'field'     => 'start',
        Severity: Minor
        Found in src/Controller/BookingsController.php - About 1 hr to fix

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

              protected function _post($params = [])
              {
                  // Create state-aware booking from params
                  $booking = $this->stateAwareFactory->make([
                      StateAwareFactoryInterface::K_DATA => $this->_buildInsertRecord($params),
          Severity: Minor
          Found in src/Controller/BookingsController.php - About 1 hr to fix

            Method _patch has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function _patch($params = [])
                {
                    try {
                        $id = $this->_containerGet($params, 'id');
                    } catch (NotFoundExceptionInterface $exception) {
            Severity: Minor
            Found in src/Controller/BookingsController.php - About 1 hr to fix

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

                      FactoryInterface $iteratorFactory,
                      StateAwareFactoryInterface $bookingFactory,
                      TransitionerInterface $bookingTransitioner,
                      SelectCapableInterface $selectRm,
                      EntityManagerInterface $entityManager,
              Severity: Major
              Found in src/Controller/BookingsController.php - About 50 mins to fix

                The class BookingsController has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
                Open

                class BookingsController extends AbstractBaseCqrsController
                {
                    /* @since [*next-version*] */
                    use FactoryAwareTrait {
                        _getFactory as _getIteratorFactory;
                Severity: Minor
                Found in src/Controller/BookingsController.php by phpmd

                CouplingBetweenObjects

                Since: 1.1.0

                A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

                Example

                class Foo {
                    /**
                     * @var \foo\bar\X
                     */
                    private $x = null;
                
                    /**
                     * @var \foo\bar\Y
                     */
                    private $y = null;
                
                    /**
                     * @var \foo\bar\Z
                     */
                    private $z = null;
                
                    public function setFoo(\Foo $foo) {}
                    public function setBar(\Bar $bar) {}
                    public function setBaz(\Baz $baz) {}
                
                    /**
                     * @return \SplObjectStorage
                     * @throws \OutOfRangeException
                     * @throws \InvalidArgumentException
                     * @throws \ErrorException
                     */
                    public function process(\Iterator $it) {}
                
                    // ...
                }

                Source https://phpmd.org/rules/design.html#couplingbetweenobjects

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

                            $id = $this->_containerGet($params, 'id');
                Severity: Minor
                Found in src/Controller/BookingsController.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

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

                        $id = $this->entityManager->add($booking->getState());
                Severity: Minor
                Found in src/Controller/BookingsController.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

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

                            $id = $this->_containerGet($params, 'id');
                Severity: Minor
                Found in src/Controller/BookingsController.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

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

                        $b = $this->exprBuilder;
                Severity: Minor
                Found in src/Controller/BookingsController.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

                There are no issues that match your filters.

                Category
                Status