| Total Complexity | 40 |
| Total Lines | 241 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| 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 |
||
| 21 | class CommandFacade extends AbstractFacade |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * Connection for exploring indexes and EXPLAIN (to not replace FOUND_ROWS()) |
||
| 25 | * //! PDO - silent error |
||
| 26 | * |
||
| 27 | * @var ConnectionInterface |
||
| 28 | */ |
||
| 29 | protected $connection = null; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var array |
||
| 33 | */ |
||
| 34 | protected $results; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var float |
||
| 38 | */ |
||
| 39 | protected $duration; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Initialize the facade |
||
| 43 | * |
||
| 44 | * @param AbstractFacade $dbFacade |
||
| 45 | * @param TimerService $timer |
||
| 46 | * @param LoggingService|null $logging |
||
| 47 | */ |
||
| 48 | public function __construct(AbstractFacade $dbFacade, |
||
| 49 | protected TimerService $timer, protected LoggingService|null $logging) |
||
| 50 | { |
||
| 51 | parent::__construct($dbFacade); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Open a second connection to the server |
||
| 56 | * |
||
| 57 | * @return void |
||
| 58 | */ |
||
| 59 | private function createConnection() |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @param array $row |
||
| 71 | * @param array $blobs |
||
| 72 | * @param array $types |
||
| 73 | * |
||
| 74 | * @return array |
||
| 75 | */ |
||
| 76 | protected function values(array $row, array $blobs, array $types): array |
||
| 95 | } |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @param mixed $statement |
||
| 99 | * @param int $limit |
||
| 100 | * |
||
| 101 | * @return string |
||
| 102 | */ |
||
| 103 | private function message($statement, int $limit): string |
||
| 114 | } |
||
| 115 | |||
| 116 | /** |
||
| 117 | * Print select result |
||
| 118 | * From editing.inc.php |
||
| 119 | * |
||
| 120 | * @param mixed $statement |
||
| 121 | * @param int $limit |
||
| 122 | * |
||
| 123 | * @return array |
||
| 124 | */ |
||
| 125 | protected function select($statement, int $limit = 0): array |
||
| 169 | } |
||
| 170 | |||
| 171 | /** |
||
| 172 | * @param QueryEntity $queryEntity |
||
| 173 | * |
||
| 174 | * @return bool |
||
| 175 | */ |
||
| 176 | private function executeCommand(QueryEntity $queryEntity): bool |
||
| 209 | } |
||
| 210 | |||
| 211 | /** |
||
| 212 | * Execute a set of queries |
||
| 213 | * |
||
| 214 | * @param string $queries The queries to execute |
||
| 215 | * @param int $limit The max number of rows to return |
||
| 216 | * @param bool $errorStops Stop executing the requests in case of error |
||
| 217 | * @param bool $onlyErrors Return only errors |
||
| 218 | * |
||
| 219 | * @return array |
||
| 220 | */ |
||
| 221 | public function executeCommands(string $queries, int $limit, bool $errorStops, bool $onlyErrors): array |
||
| 265 |
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.