Total Complexity | 55 |
Total Lines | 323 |
Duplicated Lines | 0 % |
Changes | 13 | ||
Bugs | 0 | Features | 0 |
Complex classes like RunnableSelect 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 RunnableSelect, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
16 | */ |
||
17 | public function aliasReplacer(): AliasReplacer; |
||
18 | |||
19 | /** |
||
20 | * @param array<string, mixed> $values |
||
21 | * @return $this |
||
22 | */ |
||
23 | public function bindValues(array $values); |
||
24 | |||
25 | /** |
||
26 | * @param string $key |
||
27 | * @param string|int|bool|float|null $value |
||
28 | * @return $this |
||
29 | */ |
||
30 | public function bindValue(string $key, $value); |
||
31 | |||
32 | /** |
||
33 | * @return $this |
||
34 | */ |
||
35 | public function clearValues(); |
||
36 | |||
37 | /** |
||
38 | * @param bool $preserveTypes |
||
39 | * @return $this |
||
40 | */ |
||
41 | public function setPreserveTypes(bool $preserveTypes = true); |
||
42 | |||
43 | /** |
||
44 | * @param null|callable(array<string, mixed>): array<string, mixed>|callable(array<string, mixed>): void|callable(array<string, mixed>): DBIgnoreRow $callback |
||
45 | * @return array<int, array<string, mixed>> |
||
46 | */ |
||
47 | public function fetchRows($callback = null): array; |
||
48 | |||
49 | /** |
||
50 | * @param null|callable(array<string, mixed>): (array<mixed, mixed>|null|void) $callback |
||
51 | * @return Generator<int, array<string, mixed>> |
||
52 | */ |
||
53 | public function fetchRowsLazy($callback = null); |
||
54 | |||
55 | /** |
||
56 | * @param null|callable(array<string, mixed>): array<string, mixed>|callable(array<string, mixed>): void|callable(array<string, mixed>): DBIgnoreRow $callback |
||
57 | * @return array<string, mixed> |
||
58 | */ |
||
59 | public function fetchRow($callback = null): array; |
||
60 | |||
61 | /** |
||
62 | * @template T |
||
63 | * @template U |
||
64 | * @param class-string<T> $className |
||
|
|||
65 | * @param null|callable(T): U $callback |
||
66 | * @return T[]|U[] |
||
67 | */ |
||
68 | public function fetchObjects(string $className = 'stdClass', $callback = null): array; |
||
69 | |||
70 | /** |
||
71 | * @template T |
||
72 | * @template U |
||
73 | * @param class-string<T> $className |
||
74 | * @param null|callable(T): U $callback |
||
75 | * @return Generator<int, T|U> |
||
76 | */ |
||
77 | public function fetchObjectsLazy($className = null, $callback = null); |
||
78 | |||
79 | /** |
||
80 | * @template T |
||
81 | * @template U |
||
82 | * @param class-string<T> $className |
||
83 | * @param null|callable(T): U $callback |
||
84 | * @return T|U |
||
85 | */ |
||
86 | public function fetchObject($className = null, $callback = null); |
||
87 | |||
88 | /** |
||
89 | * @param bool $treatValueAsArray |
||
90 | * @return array<mixed, mixed> |
||
91 | */ |
||
92 | public function fetchKeyValue($treatValueAsArray = false): array; |
||
93 | |||
94 | /** |
||
95 | * @param string[] $fields |
||
96 | * @return array<string, array<int, mixed>> |
||
97 | */ |
||
98 | public function fetchGroups(array $fields): array; |
||
99 | |||
100 | /** |
||
101 | * @template T |
||
102 | * @param null|callable(null|bool|int|float|string): T $fn |
||
103 | * @return array<int, T|string> |
||
104 | */ |
||
105 | public function fetchArray(?callable $fn = null): array; |
||
106 | |||
107 | /** |
||
108 | * @template TDefault |
||
109 | * @template TCastFn |
||
110 | * @param TDefault $default |
||
111 | * @param null|callable(null|bool|string|int|float): TCastFn $fn |
||
112 | * @return null|bool|string|int|float|TDefault|TCastFn |
||
113 | */ |
||
114 | public function fetchValue($default = null, ?callable $fn = null); |
||
115 | |||
116 | /** |
||
117 | * @return int |
||
118 | */ |
||
119 | public function getFoundRows(): int; |
||
120 | |||
121 | /** |
||
122 | * @return Generator<int, array<string, mixed>> |
||
123 | */ |
||
124 | public function getIterator(); |
||
125 | } |
||
126 |