| Total Complexity | 42 |
| Total Lines | 245 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
Complex classes like CommandFacade often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use CommandFacade, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 22 | class CommandFacade extends AbstractFacade |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * Connection for exploring indexes and EXPLAIN (to not replace FOUND_ROWS()) |
||
| 26 | * //! PDO - silent error |
||
| 27 | * |
||
| 28 | * @var ConnectionInterface |
||
| 29 | */ |
||
| 30 | protected $connection = null; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var array |
||
| 34 | */ |
||
| 35 | protected $results; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var float |
||
| 39 | */ |
||
| 40 | protected $duration; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Initialize the facade |
||
| 44 | * |
||
| 45 | * @param AbstractFacade $dbFacade |
||
| 46 | * @param TimerService $timer |
||
| 47 | * @param QueryLogger|null $queryLogger |
||
| 48 | */ |
||
| 49 | public function __construct(AbstractFacade $dbFacade, |
||
| 50 | protected TimerService $timer, protected QueryLogger|null $queryLogger) |
||
| 51 | { |
||
| 52 | parent::__construct($dbFacade); |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Open a second connection to the server |
||
| 57 | * |
||
| 58 | * @return void |
||
| 59 | */ |
||
| 60 | private function openSecondConnection() |
||
| 68 | } |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @param array $row |
||
| 73 | * @param array $blobs |
||
| 74 | * @param array $types |
||
| 75 | * |
||
| 76 | * @return array |
||
| 77 | */ |
||
| 78 | protected function values(array $row, array $blobs, array $types): array |
||
| 97 | } |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @param mixed $statement |
||
| 101 | * @param int $limit |
||
| 102 | * |
||
| 103 | * @return string |
||
| 104 | */ |
||
| 105 | private function message($statement, int $limit): string |
||
| 116 | } |
||
| 117 | |||
| 118 | /** |
||
| 119 | * Print select result |
||
| 120 | * From editing.inc.php |
||
| 121 | * |
||
| 122 | * @param mixed $statement |
||
| 123 | * @param int $limit |
||
| 124 | * |
||
| 125 | * @return array |
||
| 126 | */ |
||
| 127 | protected function select($statement, int $limit = 0): array |
||
| 171 | } |
||
| 172 | |||
| 173 | /** |
||
| 174 | * @param QueryEntity $queryEntity |
||
| 175 | * |
||
| 176 | * @return bool |
||
| 177 | */ |
||
| 178 | private function executeCommand(QueryEntity $queryEntity): bool |
||
| 214 | } |
||
| 215 | |||
| 216 | /** |
||
| 217 | * Execute a set of queries |
||
| 218 | * |
||
| 219 | * @param string $queries The queries to execute |
||
| 220 | * @param int $limit The max number of rows to return |
||
| 221 | * @param bool $errorStops Stop executing the requests in case of error |
||
| 222 | * @param bool $onlyErrors Return only errors |
||
| 223 | * |
||
| 224 | * @return array |
||
| 225 | */ |
||
| 226 | public function executeCommands(string $queries, int $limit, bool $errorStops, bool $onlyErrors): array |
||
| 270 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.