1.2.1212. Too Many Finds¶
Too many methods called ‘find*’ in this class. It is may be time to consider the Specification pattern.
<?php
// quite a fishy interface
interface UserInterface {
public function findByEmail($email);
public function findByUsername($username);
public function findByFirstName($firstname);
public function findByLastName($lastname);
public function findByName($name);
public function findById($id);
public function insert($user);
public function update($user);
}
?>
Name |
Default |
Type |
Description |
minimumFinds |
5 |
integer |
Minimal number of prefixed methods to report. |
findPrefix |
find |
string |
list of prefix to use when detecting the ‘find’. Comma-separated list, case insensitive. |
findSuffix |
string |
list of fix to use when detecting the ‘find’. Comma-separated list, case insensitive. |
See also On Taming Repository Classes in Doctrine and specifications.
1.2.1212.1. Connex PHP features¶
1.2.1212.1.1. Suggestions¶
Split the class into smaller classes
Remove some of the find* methods
1.2.1212.1.2. Specs¶
Short name |
Classes/TooManyFinds |
Rulesets |
|
Exakat since |
0.10.5 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Slow (1 hour) |
Precision |
Very high |
Available in |