The class Router has an overall complexity of 53 which is very high. The configured complexity threshold is 50. Open
class Router implements LoggerAwareInterface
{
use LoggerAwareTrait;
- Exclude checks
Method __invoke
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __invoke(Request $request, Response $response, callable $next)
{
$this->log('start');
if ($this->isDocumentationRoute($request)) {
Function __invoke
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function __invoke(Request $request, Response $response, callable $next)
{
$this->log('start');
if ($this->isDocumentationRoute($request)) {
- 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
Function getSecurity
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function getSecurity(array $operation)
{
$securityRequirement = [];
if (isset($operation['security'])) {
- 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
Function resolveRefs
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function resolveRefs(array $chunk)
{
$resolvedChunk = [];
foreach ($chunk as $key => $value) {
if ($key === '$ref') {
- 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
Function getParameters
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function getParameters(array $pathItem, array $operation)
{
$uniqueParameters = [];
if (array_key_exists('parameters', $pathItem)) {
foreach ($pathItem['parameters'] as $parameter) {
- 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
Missing class import via use statement (line '269', column '27'). Open
throw new \Exception('Security scheme is not defined');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '174', column '23'). Open
throw new \Exception('invalid json reference found in swagger');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '183', column '27'). Open
throw new \Exception('reference not found in swagger');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '54', column '27'). Open
throw new \Exception('Invalid swagger - could not decode');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '261', column '23'). Open
throw new \Exception('No security schemes defined');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid unused parameters such as '$request'. Open
protected function encodeResponse(Request $request, Response $response)
- 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
}
}