Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
8 | class ContainerResource extends Resource |
||
9 | { |
||
10 | /** |
||
11 | * List containers. |
||
12 | * |
||
13 | * @param array $parameters List of parameters |
||
14 | * |
||
15 | * (bool)all: Show all containers. Only running containers are shown by default (i.e., this defaults to false) |
||
16 | * (int)limit: Show <limit> last created containers, include non-running ones. |
||
17 | * (string)since: Show only containers created since Id, include non-running ones. |
||
18 | * (string)before: Show only containers created before Id, include non-running ones. |
||
19 | * (bool)size: 1/True/true or 0/False/false, Show the containers sizes. |
||
20 | * (array)filters: A JSON encoded value of the filters (a map[string][]string) to process on the containers list |
||
21 | * @param string $fetch Fetch mode (object or response) |
||
22 | * |
||
23 | * @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerConfig[] |
||
24 | */ |
||
25 | public function findAll($parameters = [], $fetch = self::FETCH_OBJECT) |
||
48 | |||
49 | /** |
||
50 | * Create a container. |
||
51 | * |
||
52 | * @param \Docker\API\Model\ContainerConfig $container Container to create |
||
53 | * @param array $parameters List of parameters |
||
54 | * |
||
55 | * (string)name: Assign the specified name to the container. Must match /?[a-zA-Z0-9_-]+. |
||
56 | * (string)Content-Type: Content Type of input |
||
57 | * @param string $fetch Fetch mode (object or response) |
||
58 | * |
||
59 | * @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerCreateResult |
||
60 | */ |
||
61 | public function create(\Docker\API\Model\ContainerConfig $container, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
81 | |||
82 | /** |
||
83 | * Return low-level information on the container id. |
||
84 | * |
||
85 | * @param string $id The container id or name |
||
86 | * @param array $parameters List of parameters |
||
87 | * @param string $fetch Fetch mode (object or response) |
||
88 | * |
||
89 | * @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\Container |
||
90 | */ |
||
91 | public function find($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
109 | |||
110 | /** |
||
111 | * List processes running inside the container id. |
||
112 | * |
||
113 | * @param string $id The container id or name |
||
114 | * @param array $parameters List of parameters |
||
115 | * |
||
116 | * (string)ps_args: ps arguments to use (e.g., aux) |
||
117 | * @param string $fetch Fetch mode (object or response) |
||
118 | * |
||
119 | * @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerTop |
||
120 | */ |
||
121 | public function listProcesses($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
140 | |||
141 | /** |
||
142 | * Get stdout and stderr logs from the container id. Note: This endpoint works only for containers with json-file logging driver. |
||
143 | * |
||
144 | * @param string $id The container id or name |
||
145 | * @param array $parameters List of parameters |
||
146 | * |
||
147 | * (bool)follow: 1/True/true or 0/False/false, return stream. Default false. |
||
148 | * (bool)stdout: 1/True/true or 0/False/false, show stdout log. Default false. |
||
149 | * (bool)stderr: 1/True/true or 0/False/false, show stderr log. Default false. |
||
150 | * (int)since: UNIX timestamp (integer) to filter logs. Specifying a timestamp will only output log-entries since that timestamp. Default: 0 (unfiltered) |
||
151 | * (bool)timestamps: 1/True/true or 0/False/false, print timestamps for every log line. |
||
152 | * (string)tail: Output specified number of lines at the end of logs: all or <number>. Default all. |
||
153 | * @param string $fetch Fetch mode (object or response) |
||
154 | * |
||
155 | * @return \Psr\Http\Message\ResponseInterface |
||
156 | */ |
||
157 | View Code Duplication | public function logs($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
176 | |||
177 | /** |
||
178 | * Inspect changes on a container’s filesystem. |
||
179 | * |
||
180 | * @param string $id The container id or name |
||
181 | * @param array $parameters List of parameters |
||
182 | * |
||
183 | * (int)kind: Kind of changes |
||
184 | * @param string $fetch Fetch mode (object or response) |
||
185 | * |
||
186 | * @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerChange[] |
||
187 | */ |
||
188 | public function changes($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
207 | |||
208 | /** |
||
209 | * Export the contents of container id. |
||
210 | * |
||
211 | * @param string $id The container id or name |
||
212 | * @param array $parameters List of parameters |
||
213 | * @param string $fetch Fetch mode (object or response) |
||
214 | * |
||
215 | * @return \Psr\Http\Message\ResponseInterface |
||
216 | */ |
||
217 | public function export($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
230 | |||
231 | /** |
||
232 | * This endpoint returns a live stream of a container’s resource usage statistics. |
||
233 | * |
||
234 | * @param string $id The container id or name |
||
235 | * @param array $parameters List of parameters |
||
236 | * |
||
237 | * (bool)stream: Stream stats |
||
238 | * @param string $fetch Fetch mode (object or response) |
||
239 | * |
||
240 | * @return \Psr\Http\Message\ResponseInterface |
||
241 | */ |
||
242 | public function stats($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
256 | |||
257 | /** |
||
258 | * Resize the TTY for container with id. The unit is number of characters. You must restart the container for the resize to take effect. |
||
259 | * |
||
260 | * @param string $id The container id or name |
||
261 | * @param array $parameters List of parameters |
||
262 | * |
||
263 | * (int)h: Height of the tty session |
||
264 | * (int)w: Width of the tty session |
||
265 | * @param string $fetch Fetch mode (object or response) |
||
266 | * |
||
267 | * @return \Psr\Http\Message\ResponseInterface |
||
268 | */ |
||
269 | View Code Duplication | public function resize($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
284 | |||
285 | /** |
||
286 | * Start the container id. |
||
287 | * |
||
288 | * @param string $id The container id or name |
||
289 | * @param array $parameters List of parameters |
||
290 | * @param string $fetch Fetch mode (object or response) |
||
291 | * |
||
292 | * @return \Psr\Http\Message\ResponseInterface |
||
293 | */ |
||
294 | public function start($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
307 | |||
308 | /** |
||
309 | * Stop the container id. |
||
310 | * |
||
311 | * @param string $id The container id or name |
||
312 | * @param array $parameters List of parameters |
||
313 | * |
||
314 | * (int)t: number of seconds to wait before killing the container |
||
315 | * @param string $fetch Fetch mode (object or response) |
||
316 | * |
||
317 | * @return \Psr\Http\Message\ResponseInterface |
||
318 | */ |
||
319 | public function stop($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
333 | |||
334 | /** |
||
335 | * Restart the container id. |
||
336 | * |
||
337 | * @param string $id The container id or name |
||
338 | * @param array $parameters List of parameters |
||
339 | * |
||
340 | * (int)t: number of seconds to wait before killing the container |
||
341 | * @param string $fetch Fetch mode (object or response) |
||
342 | * |
||
343 | * @return \Psr\Http\Message\ResponseInterface |
||
344 | */ |
||
345 | public function restart($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
359 | |||
360 | /** |
||
361 | * Send a posix signal to a container. |
||
362 | * |
||
363 | * @param string $id The container id or name |
||
364 | * @param array $parameters List of parameters |
||
365 | * @param string $fetch Fetch mode (object or response) |
||
366 | * |
||
367 | * @return \Psr\Http\Message\ResponseInterface |
||
368 | */ |
||
369 | public function kill($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
382 | |||
383 | /** |
||
384 | * Rename the container id to a new_name. |
||
385 | * |
||
386 | * @param string $id The container id or name |
||
387 | * @param array $parameters List of parameters |
||
388 | * |
||
389 | * (string)name: New name for the container |
||
390 | * @param string $fetch Fetch mode (object or response) |
||
391 | * |
||
392 | * @return \Psr\Http\Message\ResponseInterface |
||
393 | */ |
||
394 | public function rename($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
408 | |||
409 | /** |
||
410 | * Pause the container id. |
||
411 | * |
||
412 | * @param string $id The container id or name |
||
413 | * @param array $parameters List of parameters |
||
414 | * @param string $fetch Fetch mode (object or response) |
||
415 | * |
||
416 | * @return \Psr\Http\Message\ResponseInterface |
||
417 | */ |
||
418 | public function pause($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
431 | |||
432 | /** |
||
433 | * Unpause the container id. |
||
434 | * |
||
435 | * @param string $id The container id or name |
||
436 | * @param array $parameters List of parameters |
||
437 | * @param string $fetch Fetch mode (object or response) |
||
438 | * |
||
439 | * @return \Psr\Http\Message\ResponseInterface |
||
440 | */ |
||
441 | public function unpause($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
454 | |||
455 | /** |
||
456 | * Attach to the container id. |
||
457 | * |
||
458 | * @param string $id The container id or name |
||
459 | * @param array $parameters List of parameters |
||
460 | * |
||
461 | * (string)logs: 1/True/true or 0/False/false, return logs. Default false |
||
462 | * (string)stream: 1/True/true or 0/False/false, return stream. Default false |
||
463 | * (string)stdin: 1/True/true or 0/False/false, if stream=true, attach to stdin. Default false. |
||
464 | * (string)stdout: 1/True/true or 0/False/false, if logs=true, return stdout log, if stream=true, attach to stdout. Default false. |
||
465 | * (string)stderr: 1/True/true or 0/False/false, if logs=true, return stderr log, if stream=true, attach to stderr. Default false. |
||
466 | * @param string $fetch Fetch mode (object or response) |
||
467 | * |
||
468 | * @return \Psr\Http\Message\ResponseInterface |
||
469 | */ |
||
470 | View Code Duplication | public function attach($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
488 | |||
489 | /** |
||
490 | * Block until container id stops, then returns the exit code. |
||
491 | * |
||
492 | * @param string $id The container id or name |
||
493 | * @param array $parameters List of parameters |
||
494 | * @param string $fetch Fetch mode (object or response) |
||
495 | * |
||
496 | * @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerWait |
||
497 | */ |
||
498 | public function wait($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
516 | |||
517 | /** |
||
518 | * Remove the container id from the filesystem. |
||
519 | * |
||
520 | * @param string $id The container id or name |
||
521 | * @param array $parameters List of parameters |
||
522 | * |
||
523 | * (string)v: 1/True/true or 0/False/false, Remove the volumes associated to the container. Default false. |
||
524 | * (string)force: 1/True/true or 0/False/false, Kill then remove the container. Default false. |
||
525 | * @param string $fetch Fetch mode (object or response) |
||
526 | * |
||
527 | * @return \Psr\Http\Message\ResponseInterface |
||
528 | */ |
||
529 | View Code Duplication | public function remove($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
544 | |||
545 | /** |
||
546 | * Get an tar archive of a resource in the filesystem of container id. |
||
547 | * |
||
548 | * @param string $id The container id or name |
||
549 | * @param array $parameters List of parameters |
||
550 | * |
||
551 | * (string)path: Resource in the container’s filesystem to archive. |
||
552 | * @param string $fetch Fetch mode (object or response) |
||
553 | * |
||
554 | * @return \Psr\Http\Message\ResponseInterface |
||
555 | */ |
||
556 | public function getArchive($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
570 | |||
571 | /** |
||
572 | * Retrieving information about files and folders in a container. |
||
573 | * |
||
574 | * @param string $id The container id or name |
||
575 | * @param array $parameters List of parameters |
||
576 | * |
||
577 | * (string)path: Resource in the container’s filesystem to archive. |
||
578 | * @param string $fetch Fetch mode (object or response) |
||
579 | * |
||
580 | * @return \Psr\Http\Message\ResponseInterface |
||
581 | */ |
||
582 | public function getArchiveInformation($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
596 | |||
597 | /** |
||
598 | * Upload a tar archive to be extracted to a path in the filesystem of container id. |
||
599 | * |
||
600 | * @param string $id The container id or name |
||
601 | * @param string $inputStream The input stream must be a tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz. |
||
602 | * @param array $parameters List of parameters |
||
603 | * |
||
604 | * (string)path: Path to a directory in the container to extract the archive’s contents into. |
||
605 | * (string)noOverwriteDirNonDir: If “1”, “true”, or “True” then it will be an error if unpacking the given content would cause an existing directory to be replaced with a non-directory and vice versa. |
||
606 | * @param string $fetch Fetch mode (object or response) |
||
607 | * |
||
608 | * @return \Psr\Http\Message\ResponseInterface |
||
609 | */ |
||
610 | public function putArchive($id, string $inputStream, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
625 | } |
||
626 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.