Conditions | 6 |
Paths | 6 |
Total Lines | 53 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
75 | private function pruneProcessList() |
||
76 | { |
||
77 | // should the processes persist? |
||
78 | if ($this->st->getPersistProcesses()) { |
||
79 | return; |
||
80 | } |
||
81 | |||
82 | // get the processes table, if we have one |
||
83 | $table = $this->getTable(); |
||
84 | if (!$table) { |
||
85 | return; |
||
86 | } |
||
87 | |||
88 | foreach ($table as $key => $details) { |
||
89 | list($hostId, $pid) = explode(":", $key); |
||
90 | if ($hostId != "localhost") { |
||
91 | continue; |
||
92 | } |
||
93 | |||
94 | if (!posix_kill($pid, 0)) { |
||
95 | // process no longer running |
||
96 | unset($table->$key); |
||
97 | } |
||
98 | } |
||
99 | |||
100 | $this->removeTablesIfEmpty(); |
||
101 | $this->st->saveRuntimeConfig(); |
||
102 | |||
103 | return; |
||
104 | |||
105 | /* |
||
106 | // shorthand |
||
107 | $output = $this->output; |
||
108 | |||
109 | // do we have anything to shutdown? |
||
110 | $screenSessions = fromShell()->getAllScreenSessions(); |
||
111 | if (count($screenSessions) == 0) { |
||
112 | // nothing to do |
||
113 | return; |
||
114 | } |
||
115 | |||
116 | // if we get here, there are background jobs running |
||
117 | echo "\n"; |
||
118 | if (count($screenSessions) == 1) { |
||
119 | $output->logCliInfo("There is 1 background process still running"); |
||
120 | } |
||
121 | else { |
||
122 | $output->logCliInfo("There are " . count($screenSessions) . " background processes still running"); |
||
123 | } |
||
124 | $output->logCliInfo("Use 'storyplayer list-processes' to see the list of background processes"); |
||
125 | $output->logCliInfo("Use 'storyplayer kill-processes' to stop any background processes"); |
||
126 | */ |
||
127 | } |
||
128 | |||
130 |