Function reverseTransform
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
public function reverseTransform($value)
{
$result = new ArrayCollection();
if (is_array($value)) {
foreach ($value as $type => $perimeters) {
- Read upRead up
- Create a ticketCreate a ticket
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 reverseTransform
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function reverseTransform($value)
{
$result = new ArrayCollection();
if (is_array($value)) {
foreach ($value as $type => $perimeters) {
- Create a ticketCreate a ticket
Avoid using static access to class '\OpenOrchestra\Backoffice\GeneratePerimeter\GeneratePerimeterManager' in method 'reverseTransform'. Open
$name = GeneratePerimeterManager::changeNameToPath($name);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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 '\OpenOrchestra\Backoffice\GeneratePerimeter\GeneratePerimeterManager' in method 'transform'. Open
$key = GeneratePerimeterManager::changePathToName($path);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Call to method __construct
from undeclared class \Doctrine\Common\Collections\ArrayCollection
Open
$result = new ArrayCollection();
- Create a ticketCreate a ticket
- Exclude checks
Returning type \Doctrine\Common\Collections\ArrayCollection
but reverseTransform()
is declared to return array
Open
return $result;
- Create a ticketCreate a ticket
- Exclude checks
Call to method set
from undeclared class \Doctrine\Common\Collections\ArrayCollection
Open
$result->set($type, $perimeterCollection);
- Create a ticketCreate a ticket
- Exclude checks
Call to method getOwner
on non-class type array
Open
$configuration = $this->generatePerimeterManager->generatePerimeters($value->getOwner()->getSite()->getSiteId());
- Create a ticketCreate a ticket
- Exclude checks
Call to method toArray
on non-class type array
Open
$value = $value->toArray();
- Create a ticketCreate a ticket
- Exclude checks
Class implements undeclared interface \Symfony\Component\Form\DataTransformerInterface
Open
class GroupPerimeterTransformer implements DataTransformerInterface
- Create a ticketCreate a ticket
- Exclude checks
Avoid excessively long variable names like $generatePerimeterManager. Keep variable name length under 20. Open
public function __construct(GeneratePerimeterManager $generatePerimeterManager)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $generatePerimeterManager. Keep variable name length under 20. Open
protected $generatePerimeterManager;
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Expected 1 space after FUNCTION keyword; 0 found Open
array_walk($paths, function($path) use (&$result, $items, $type) {
- Create a ticketCreate a ticket
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
array_walk($perimeters, function(&$name) {
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$configuration = $this->generatePerimeterManager->generatePerimeters($value->getOwner()->getSite()->getSiteId());
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$result[$type][$key] = $result[$type][$key] || preg_match('/^' . preg_quote($item, '/') . '.*$/', $path);
- Create a ticketCreate a ticket
- Exclude checks
Expected 1 space after FOREACH keyword; 0 found Open
foreach($items as $item) {
- Create a ticketCreate a ticket
- Exclude checks