Conditions | 9 |
Paths | 13 |
Total Lines | 66 |
Code Lines | 46 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
42 | protected function detectEntity(array $row): AbstractKsql |
||
43 | { |
||
44 | if (isset($row['queries'])) { |
||
45 | $queries = []; |
||
46 | foreach ($row['queries']['queries'] as $query) { |
||
47 | $queries[] = new RunningQuery( |
||
48 | $query['statementText'], |
||
49 | $query['sinks'], |
||
50 | $query['id'] |
||
51 | ); |
||
52 | } |
||
53 | |||
54 | return new Queries($row['queries']['statementText'], $queries); |
||
55 | } |
||
56 | |||
57 | if (isset($row['description'])) { |
||
58 | $read = $write = $schema = []; |
||
59 | foreach ($row['description']['readQueries'] as $query) { |
||
60 | $read[] = new RunningQuery( |
||
61 | $query['statementText'], |
||
62 | $query['sinks'], |
||
63 | $query['id'] |
||
64 | ); |
||
65 | } |
||
66 | foreach ($row['description']['writeQueries'] as $query) { |
||
67 | $write[] = new RunningQuery( |
||
68 | $query['statementText'], |
||
69 | $query['sinks'], |
||
70 | $query['id'] |
||
71 | ); |
||
72 | } |
||
73 | foreach ($row['description']['schema'] as $query) { |
||
74 | $schema[] = new FieldSchema( |
||
75 | $query['name'], |
||
76 | $query['type'] |
||
77 | ); |
||
78 | } |
||
79 | $description = $row['description']; |
||
80 | |||
81 | return new Description( |
||
82 | $row['description']['statementText'], |
||
83 | $description['name'], |
||
84 | $read, |
||
85 | $write, |
||
86 | $schema, |
||
87 | $description['type'], |
||
88 | $description['key'], |
||
89 | $description['timestamp'], |
||
90 | $description['statistics'], |
||
91 | $description['errorStats'], |
||
92 | $description['extended'], |
||
93 | $description['replication'], |
||
94 | $description['partitions'] |
||
95 | ); |
||
96 | } |
||
97 | if (isset($row['error'])) { |
||
98 | if (isset($row['error']['errorMessage'])) { |
||
99 | $errorMessage = $row['error']['errorMessage']; |
||
100 | |||
101 | return new KsqlStatementErrorMessage( |
||
102 | $row['error']['statementText'], |
||
103 | new KsqlErrorMessage($errorMessage['message'], $errorMessage['stackTrace']) |
||
104 | ); |
||
105 | } |
||
106 | } |
||
107 | } |
||
108 | } |
||
109 |