dingo / dingo/api

Is there a duplication here?

Open
#1,407 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
9.4k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

### Description
In the following code, **it seems that the code of the 'three if conditions which return true' is as the same as the conditions that return true,** so, is there any reasonable reason to separate that elseif in other statement ( why not use || OR )?.

```php
/**
* Determine if a controller method is in an array of options.
*
* @param array $options
*
* @return bool
*/
protected function optionsApplyToControllerMethod(array $options)
{
if (empty($options)) {
return true;
} elseif (isset($options['only']) && in_array($this->controllerMethod, $this->explodeOnPipes($options['only']))) {
return true;
} elseif (isset($options['except'])) {
return ! in_array($this->controllerMethod, $this->explodeOnPipes($options['except']));
} elseif (in_array($this->controllerMethod, $this->explodeOnPipes($options))) {
return true;
}
return false;
}
```

Click here to fix it! [Route.php](https://github.com/dingo/api/blob/master/src/Routing/Route.php)

Best regards [M. Saud](http://twitter.com/BenSaud_CS)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.