src/SchemaProcessor/SchemaProcessor.php
Method createMergedProperty
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function createMergedProperty(
Schema $schema,
PropertyInterface $property,
array $compositionProperties,
JsonSchema $propertySchema,
Method processSchema
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
JsonSchema $jsonSchema,
string $classPath,
string $className,
SchemaDefinitionDictionary $dictionary,
bool $initialClass = false,
Method generateModel
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
string $classPath,
string $className,
JsonSchema $jsonSchema,
SchemaDefinitionDictionary $dictionary,
bool $initialClass,
Function redirectMergedProperty
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
private function redirectMergedProperty(array $compositionProperties)
{
$redirectToProperty = null;
foreach ($compositionProperties as $property) {
if ($property->getNestedSchema()) {
- 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
The class SchemaProcessor has a coupling between objects value of 17. Consider to reduce the number of dependencies under 13. Open
Open
class SchemaProcessor
{
/** @var string */
protected $currentClassPath;
/** @var string */
- 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
The method processSchema has a boolean flag argument $initialClass, which is a certain sign of a Single Responsibility Principle violation. Open
Open
bool $initialClass = false,
- Read upRead up
- Exclude checks
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
Avoid unused parameters such as '$schema'. Open
Open
Schema $schema,
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
syntax error, unexpected 'protected' (T_PROTECTED), expecting variable (T_VARIABLE)
Open
Open
protected string $baseSource,
- Exclude checks
Arguments with default values must be at the end of the argument list Open
Open
bool $initialClass = false,
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
protected GeneratorConfiguration $generatorConfiguration,
- Exclude checks
Closing brace must be on a line by itself Open
Open
) {}
- Exclude checks
Multi-line function call not indented correctly; expected 16 spaces but found 20 Open
Open
$mergedPropertySchema->getJsonSchema(),
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 12 Open
Open
static fn(string $directory): string => ucfirst($directory),
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
protected string $baseSource,
- Exclude checks
Multi-line function call not indented correctly; expected 16 spaces but found 20 Open
Open
new PropertyType($mergedClassName),
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
protected string $destination,
- Exclude checks
Multi-line function call not indented correctly; expected 16 spaces but found 20 Open
Open
'MergedProperty',
- Exclude checks
Multi-line function call not indented correctly; expected 28 spaces but found 24 Open
Open
// corresponding to the defined constraints of the composition property.
- Exclude checks
Multi-line function call not indented correctly; expected 28 spaces but found 24 Open
Open
// don't validate fields in merged properties. All fields were validated before
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
protected RenderQueue $renderQueue,
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
Open
))
- Exclude checks