src/Controller/BookingsController.php
File BookingsController.php
has 381 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
namespace RebelCode\EddBookings\RestApi\Controller;
use Dhii\Data\Container\ContainerSetCapableTrait;
Method _getUpdateParamFieldMapping
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function _getUpdateParamFieldMapping()
{
return [
'start' => [
'field' => 'start',
Method _getSelectConditionParamMapping
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function _getSelectConditionParamMapping()
{
return [
'id' => [
'compare' => 'eq',
Method _getInsertParamFieldMapping
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function _getInsertParamFieldMapping()
{
return [
'start' => [
'field' => 'start',
Method _post
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function _post($params = [])
{
// Create state-aware booking from params
$booking = $this->stateAwareFactory->make([
StateAwareFactoryInterface::K_DATA => $this->_buildInsertRecord($params),
Method _patch
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function _patch($params = [])
{
try {
$id = $this->_containerGet($params, 'id');
} catch (NotFoundExceptionInterface $exception) {
Method __construct
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
FactoryInterface $iteratorFactory,
StateAwareFactoryInterface $bookingFactory,
TransitionerInterface $bookingTransitioner,
SelectCapableInterface $selectRm,
EntityManagerInterface $entityManager,
The class BookingsController has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13. Open
Open
class BookingsController extends AbstractBaseCqrsController
{
/* @since [*next-version*] */
use FactoryAwareTrait {
_getFactory as _getIteratorFactory;
- Read upRead up
- Exclude checks
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
Open
$id = $this->_containerGet($params, 'id');
- Read upRead up
- Exclude checks
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
Open
$id = $this->entityManager->add($booking->getState());
- Read upRead up
- Exclude checks
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
Open
$id = $this->_containerGet($params, 'id');
- Read upRead up
- Exclude checks
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
Open
$b = $this->exprBuilder;
- Read upRead up
- Exclude checks
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;
}
}
}