Showing 70 of 70 total issues
File ServicesEntityManager.php
has 409 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace RebelCode\EddBookings\Services\Storage;
use ArrayAccess;
ServicesEntityManager
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class ServicesEntityManager implements EntityManagerInterface
{
/* @since [*next-version*] */
use ServicesPostKeyMapAwareTrait;
The class ServicesEntityManager has an overall complexity of 62 which is very high. The configured complexity threshold is 50. Open
class ServicesEntityManager implements EntityManagerInterface
{
/* @since [*next-version*] */
use ServicesPostKeyMapAwareTrait;
- Exclude checks
Method _getServices
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _getServices()
{
return [
/**
* The services manager.
Method _updateAvailability
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _updateAvailability($id, $ir)
{
$b = $this->exprBuilder;
// Get the service's timezone and availability
Method _buildWpQueryArgs
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _buildWpQueryArgs($query = [], $limit = null, $offset = null, $orderBy = null, $desc = false)
{
// Get post key field map
$postKeyMap = $this->_getServicesPostKeyMap();
Avoid using short method names like GetEddServicePricesCapableTrait::__(). The configured minimum method name length is 3. Open
abstract protected function __($string, $args = [], $context = null);
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Method __invoke
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __invoke()
{
/* @var $event EventInterface */
$event = func_get_arg(0);
Method _processSessionRuleData
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _processSessionRuleData($serviceId, $scheduleId, $ruleData, $serviceTz)
{
$allDay = $this->_containerGet($ruleData, 'isAllDay');
// Parse the service timezone name into a timezone object
Method _entityToServiceIr
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _entityToServiceIr($entity)
{
$eArray = $this->_normalizeArray($entity);
$postKeys = $this->_getServicesPostKeyMap();
Function __invoke
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function __invoke()
{
$event = func_get_arg(0);
if (!($event instanceof EventInterface)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method __invoke
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __invoke()
{
$event = func_get_arg(0);
if (!($event instanceof EventInterface)) {
Method _getServicesPostKeyMap
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _getServicesPostKeyMap()
{
return [
// Core service fields
'id' => 'ID',
Method _getEddServicePrices
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _getEddServicePrices($serviceId)
{
try {
$service = $this->_getServicesManager()->get($serviceId);
} catch (NotFoundExceptionInterface $exception) {
Method __construct
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
$postType,
$metaPrefix,
EntityManagerInterface $resourcesManager,
SelectCapableInterface $rulesSelectRm,
InsertCapableInterface $rulesInsertRm,
Function _entityToServiceIr
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function _entityToServiceIr($entity)
{
$eArray = $this->_normalizeArray($entity);
$postKeys = $this->_getServicesPostKeyMap();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method __construct
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
$key,
$dependencies,
$configFactory,
$containerFactory,
$compContainerFactory,
Avoid variables with short names like $id. Configured minimum length is 3. Open
protected function _updateAvailability($id, $ir)
- 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 $ir. Configured minimum length is 3. Open
$ir = $this->_entityToServiceIr($entity);
- 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
protected function _updateServiceExternals($id, $ir)
- 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;
}
}
}