Showing 6 of 6 total issues
Function parsePattern
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public function parsePattern($pattern) {
$count = 0;
$pattern = preg_replace("/\{(.*?)\}/", "[0-9]+", $pattern, 1, $count);
if ($count > 1) {
throw new \Exception("Pattern cannot contain more than one resource identifiers.");
- 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 parsePattern
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parsePattern($pattern) {
$count = 0;
$pattern = preg_replace("/\{(.*?)\}/", "[0-9]+", $pattern, 1, $count);
if ($count > 1) {
throw new \Exception("Pattern cannot contain more than one resource identifiers.");
Function install
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function install() {
if ( ! empty($this->collection) ) {
foreach ($this->collection as $route) {
if ($route->verb == '*') {
foreach ($this->allowed as $verb) {
- 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 handle
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function handle($request, \Closure $next, $permissions, $resource = null, $id = null) {
Function handle
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function handle($request, \Closure $next, $permissions, $resource = null, $id = null) {
$route = new Route();
$route->permissions = $permissions;
$route->resourceName = $resource;
- 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 contains
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function contains($permissionName, $resourceName = null, $resourceId = null) {
$permission = new Permission($permissionName, $resourceName, $resourceId);
foreach ($this->getAllowed() as $allowed) {
if ($allowed->equals($permission)) {
return true;
- 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"