| Conditions | 1 |
| Paths | 1 |
| Total Lines | 226 |
| Code Lines | 174 |
| 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 namespace Comodojo\Extender\Socket; |
||
| 24 | public static function inject(AbstractDaemon $daemon) { |
||
| 25 | |||
| 26 | $mmanager = $daemon->getSocket()->getRpcServer()->getMethods(); |
||
| 27 | $errors = $daemon->getSocket()->getRpcServer()->getErrors(); |
||
| 28 | |||
| 29 | $errors->add(-31002, "No record could be found"); |
||
| 30 | |||
| 31 | // ****************** |
||
| 32 | // Scheduler Commands |
||
| 33 | // ****************** |
||
| 34 | |||
| 35 | $mmanager->add( |
||
| 36 | RpcMethod::create( |
||
| 37 | "scheduler.refresh", |
||
| 38 | 'Comodojo\Extender\Socket\Commands\Scheduler\Refresh::execute', |
||
| 39 | $daemon) |
||
| 40 | ->setDescription("Refresh current scheduler's schedule") |
||
| 41 | ->setReturnType('boolean') |
||
| 42 | ); |
||
| 43 | |||
| 44 | $mmanager->add( |
||
| 45 | RpcMethod::create( |
||
| 46 | "scheduler.info", |
||
| 47 | 'Comodojo\Extender\Socket\Commands\Scheduler\Info::execute', |
||
| 48 | $daemon) |
||
| 49 | ->setDescription("Show current scheduler status") |
||
| 50 | ->setReturnType('array') |
||
| 51 | ); |
||
| 52 | |||
| 53 | $mmanager->add( |
||
| 54 | RpcMethod::create( |
||
| 55 | "scheduler.add", |
||
| 56 | 'Comodojo\Extender\Socket\Commands\Scheduler\Add::execute', |
||
| 57 | $daemon) |
||
| 58 | ->setDescription("Set new schedule") |
||
| 59 | ->addParameter('struct', 'schedule') |
||
| 60 | ->addParameter('struct', 'request') |
||
| 61 | ->setReturnType('int') |
||
| 62 | ); |
||
| 63 | |||
| 64 | $mmanager->add( |
||
| 65 | RpcMethod::create( |
||
| 66 | "scheduler.list", |
||
| 67 | 'Comodojo\Extender\Socket\Commands\Scheduler\GetList::execute', |
||
| 68 | $daemon) |
||
| 69 | ->setDescription("List all installed schedules") |
||
| 70 | ->setReturnType('array') |
||
| 71 | ); |
||
| 72 | |||
| 73 | $mmanager->add( |
||
| 74 | RpcMethod::create( |
||
| 75 | "scheduler.get", |
||
| 76 | 'Comodojo\Extender\Socket\Commands\Scheduler\Get::execute', |
||
| 77 | $daemon) |
||
| 78 | ->setDescription("Get a schedule and related task request by id (int) or name (string)") |
||
| 79 | ->addParameter('int', 'id') |
||
| 80 | ->setReturnType('array') |
||
| 81 | ->addSignature() |
||
| 82 | ->addParameter('string', 'name') |
||
| 83 | ->setReturnType('array') |
||
| 84 | ); |
||
| 85 | |||
| 86 | $mmanager->add( |
||
| 87 | RpcMethod::create( |
||
| 88 | "scheduler.edit", |
||
| 89 | 'Comodojo\Extender\Socket\Commands\Scheduler\Edit::execute', |
||
| 90 | $daemon) |
||
| 91 | ->setDescription("Edit a schedule") |
||
| 92 | ->addParameter('struct', 'schedule') |
||
| 93 | ->addParameter('struct', 'request') |
||
| 94 | ->setReturnType('boolean') |
||
| 95 | ); |
||
| 96 | |||
| 97 | $mmanager->add( |
||
| 98 | RpcMethod::create( |
||
| 99 | "scheduler.disable", |
||
| 100 | 'Comodojo\Extender\Socket\Commands\Scheduler\Disable::execute', |
||
| 101 | $daemon) |
||
| 102 | ->setDescription("Disable a schedule by id (int) or name (string)") |
||
| 103 | ->addParameter('int', 'id') |
||
| 104 | ->setReturnType('boolean') |
||
| 105 | ->addSignature() |
||
| 106 | ->addParameter('string', 'name') |
||
| 107 | ->setReturnType('boolean') |
||
| 108 | ); |
||
| 109 | |||
| 110 | $mmanager->add( |
||
| 111 | RpcMethod::create( |
||
| 112 | "scheduler.enable", |
||
| 113 | 'Comodojo\Extender\Socket\Commands\Scheduler\Enable::execute', |
||
| 114 | $daemon) |
||
| 115 | ->setDescription("Enable a schedule by id (int) or name (string)") |
||
| 116 | ->addParameter('int', 'id') |
||
| 117 | ->setReturnType('boolean') |
||
| 118 | ->addSignature() |
||
| 119 | ->addParameter('string', 'name') |
||
| 120 | ->setReturnType('boolean') |
||
| 121 | ); |
||
| 122 | |||
| 123 | $mmanager->add( |
||
| 124 | RpcMethod::create( |
||
| 125 | "scheduler.remove", |
||
| 126 | 'Comodojo\Extender\Socket\Commands\Scheduler\Remove::execute', |
||
| 127 | $daemon) |
||
| 128 | ->setDescription("Remove a schedule by id (int) or name (string)") |
||
| 129 | ->addParameter('int', 'id') |
||
| 130 | ->setReturnType('boolean') |
||
| 131 | ->addSignature() |
||
| 132 | ->addParameter('string', 'name') |
||
| 133 | ->setReturnType('boolean') |
||
| 134 | ); |
||
| 135 | |||
| 136 | // ************** |
||
| 137 | // Queue Commands |
||
| 138 | // ************** |
||
| 139 | |||
| 140 | $mmanager->add( |
||
| 141 | RpcMethod::create( |
||
| 142 | "queue.info", |
||
| 143 | 'Comodojo\Extender\Socket\Commands\Queue\Info::execute', |
||
| 144 | $daemon) |
||
| 145 | ->setDescription("Get current queue status") |
||
| 146 | ->setReturnType('array') |
||
| 147 | ); |
||
| 148 | |||
| 149 | $mmanager->add( |
||
| 150 | RpcMethod::create( |
||
| 151 | "queue.add", |
||
| 152 | 'Comodojo\Extender\Socket\Commands\Queue\Add::execute', |
||
| 153 | $daemon) |
||
| 154 | ->setDescription("Push new request to queue") |
||
| 155 | ->addParameter('struct', 'request') |
||
| 156 | ->setReturnType('string') |
||
| 157 | ); |
||
| 158 | |||
| 159 | $mmanager->add( |
||
| 160 | RpcMethod::create( |
||
| 161 | "queue.addBulk", |
||
| 162 | 'Comodojo\Extender\Socket\Commands\Queue\AddBulk::execute', |
||
| 163 | $daemon) |
||
| 164 | ->setDescription("Push new requests to queue") |
||
| 165 | ->addParameter('array', 'requests') |
||
| 166 | ->setReturnType('array') |
||
| 167 | ); |
||
| 168 | |||
| 169 | // **************** |
||
| 170 | // Worklog Commands |
||
| 171 | // **************** |
||
| 172 | |||
| 173 | $mmanager->add( |
||
| 174 | RpcMethod::create( |
||
| 175 | "worklog.count", |
||
| 176 | 'Comodojo\Extender\Socket\Commands\Worklog\Count::execute', |
||
| 177 | $daemon) |
||
| 178 | ->setDescription("Count recorded worklogs") |
||
| 179 | ->setReturnType('int') |
||
| 180 | ); |
||
| 181 | |||
| 182 | $mmanager->add( |
||
| 183 | RpcMethod::create( |
||
| 184 | "worklog.list", |
||
| 185 | 'Comodojo\Extender\Socket\Commands\Worklog\GetList::execute', |
||
| 186 | $daemon) |
||
| 187 | ->setDescription("Get a list of worklog according to (optional) filter") |
||
| 188 | ->setReturnType('array') |
||
| 189 | ->addSignature() |
||
| 190 | ->addParameter('struct', 'filter') |
||
| 191 | ->setReturnType('array') |
||
| 192 | ); |
||
| 193 | |||
| 194 | $mmanager->add( |
||
| 195 | RpcMethod::create( |
||
| 196 | "worklog.byId", |
||
| 197 | 'Comodojo\Extender\Socket\Commands\Worklog\ById::execute', |
||
| 198 | $daemon) |
||
| 199 | ->setDescription("Get a worklog from id") |
||
| 200 | ->addParameter('int', 'id') |
||
| 201 | ->setReturnType('struct') |
||
| 202 | ); |
||
| 203 | |||
| 204 | $mmanager->add( |
||
| 205 | RpcMethod::create( |
||
| 206 | "worklog.byUid", |
||
| 207 | 'Comodojo\Extender\Socket\Commands\Worklog\ByUid::execute', |
||
| 208 | $daemon) |
||
| 209 | ->setDescription("Get a worklog from uid") |
||
| 210 | ->addParameter('string', 'uid') |
||
| 211 | ->setReturnType('struct') |
||
| 212 | ); |
||
| 213 | |||
| 214 | $mmanager->add( |
||
| 215 | RpcMethod::create( |
||
| 216 | "worklog.byJid", |
||
| 217 | 'Comodojo\Extender\Socket\Commands\Worklog\ByJid::execute', |
||
| 218 | $daemon) |
||
| 219 | ->setDescription("Get a list of worklog from job id according to (optional) filter") |
||
| 220 | ->addParameter('int', 'jid') |
||
| 221 | ->setReturnType('array') |
||
| 222 | ->addSignature() |
||
| 223 | ->addParameter('int', 'jid') |
||
| 224 | ->addParameter('struct', 'filter') |
||
| 225 | ->setReturnType('array') |
||
| 226 | ); |
||
| 227 | |||
| 228 | $mmanager->add( |
||
| 229 | RpcMethod::create( |
||
| 230 | "worklog.byPid", |
||
| 231 | 'Comodojo\Extender\Socket\Commands\Worklog\ByPid::execute', |
||
| 232 | $daemon) |
||
| 233 | ->setDescription("Get a list of worklog from system pid according to (optional) filter") |
||
| 234 | ->addParameter('int', 'pid') |
||
| 235 | ->setReturnType('array') |
||
| 236 | ->addSignature() |
||
| 237 | ->addParameter('int', 'pid') |
||
| 238 | ->addParameter('struct', 'filter') |
||
| 239 | ->setReturnType('array') |
||
| 240 | ); |
||
| 241 | |||
| 242 | $mmanager->add( |
||
| 243 | RpcMethod::create( |
||
| 244 | "worklog.byPuid", |
||
| 245 | 'Comodojo\Extender\Socket\Commands\Worklog\ByPuid::execute', |
||
| 246 | $daemon) |
||
| 247 | ->setDescription("Get worklogs from parent uid") |
||
| 248 | ->addParameter('string', 'puid') |
||
| 249 | ->setReturnType('array') |
||
| 250 | ); |
||
| 255 |