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 ImageResource extends Resource |
||
9 | { |
||
10 | /** |
||
11 | * List Images. |
||
12 | * |
||
13 | * @param array $parameters List of parameters |
||
14 | * |
||
15 | * (bool)all: Show all images. Only images from a final layer (no children) are shown by default. |
||
16 | * (string)filters: A JSON encoded value of the filters (a map[string][]string) to process on the containers list |
||
17 | * (string)filter: Only return images with the specified name. |
||
18 | * (bool)digests: Show digest information, default to false |
||
19 | * @param string $fetch Fetch mode (object or response) |
||
20 | * |
||
21 | * @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ImageItem[] |
||
22 | */ |
||
23 | public function findAll($parameters = [], $fetch = self::FETCH_OBJECT) |
||
44 | |||
45 | /** |
||
46 | * Build an image from Dockerfile via stdin. |
||
47 | * |
||
48 | * @param string $inputStream The input stream must be a tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz. |
||
49 | * @param array $parameters List of parameters |
||
50 | * |
||
51 | * (string)dockerfile: Path within the build context to the Dockerfile. This is ignored if remote is specified and points to an individual filename. |
||
52 | * (string)t: A repository name (and optionally a tag) to apply to the resulting image in case of success. |
||
53 | * (string)remote: A Git repository URI or HTTP/HTTPS URI build source. If the URI specifies a filename, the file’s contents are placed into a file called Dockerfile. |
||
54 | * (bool)q: Suppress verbose build output. |
||
55 | * (bool)nocache: Do not use the cache when building the image. |
||
56 | * (string)pull: Attempt to pull the image even if an older image exists locally |
||
57 | * (bool)rm: Remove intermediate containers after a successful build (default behavior). |
||
58 | * (bool)forcerm: always remove intermediate containers (includes rm)Request Headers: |
||
59 | * (string)Content-type: Set to 'application/tar'. |
||
60 | * (string)X-Registry-Config: A base64-url-safe-encoded Registry Auth Config JSON object |
||
61 | * @param string $fetch Fetch mode (object or response) |
||
62 | * |
||
63 | * @return \Psr\Http\Message\ResponseInterface |
||
64 | */ |
||
65 | public function build(string $inputStream, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
89 | |||
90 | /** |
||
91 | * Create an image either by pulling it from the registry or by importing it. |
||
92 | * |
||
93 | * @param array $parameters List of parameters |
||
94 | * |
||
95 | * (string)fromImage: Name of the image to pull. The name may include a tag or digest. This parameter may only be used when pulling an image. |
||
96 | * (string)fromSrc: Source to import. The value may be a URL from which the image can be retrieved or - to read the image from the request body. This parameter may only be used when importing an image. |
||
97 | * (string)repo: Repository name given to an image when it is imported. The repo may include a tag. This parameter may only be used when importing an image. |
||
98 | * (string)tag: Tag or digest. |
||
99 | * (string)X-Registry-Config: A base64-encoded AuthConfig object |
||
100 | * @param string $fetch Fetch mode (object or response) |
||
101 | * |
||
102 | * @return \Psr\Http\Message\ResponseInterface |
||
103 | */ |
||
104 | public function create($parameters = [], $fetch = self::FETCH_OBJECT) |
||
122 | |||
123 | /** |
||
124 | * Return low-level information on the image name. |
||
125 | * |
||
126 | * @param array $parameters List of parameters |
||
127 | * @param string $fetch Fetch mode (object or response) |
||
128 | * |
||
129 | * @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\Image |
||
130 | */ |
||
131 | View Code Duplication | public function find($parameters = [], $fetch = self::FETCH_OBJECT) |
|
148 | |||
149 | /** |
||
150 | * Return the history of the image name. |
||
151 | * |
||
152 | * @param array $parameters List of parameters |
||
153 | * @param string $fetch Fetch mode (object or response) |
||
154 | * |
||
155 | * @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ImageHistoryItem[] |
||
156 | */ |
||
157 | View Code Duplication | public function history($parameters = [], $fetch = self::FETCH_OBJECT) |
|
174 | |||
175 | /** |
||
176 | * Push the image name on the registry. |
||
177 | * |
||
178 | * @param array $parameters List of parameters |
||
179 | * |
||
180 | * (string)tag: The tag to associate with the image on the registry. |
||
181 | * (string)X-Registry-Auth: A base64-encoded AuthConfig object |
||
182 | * @param string $fetch Fetch mode (object or response) |
||
183 | * |
||
184 | * @return \Psr\Http\Message\ResponseInterface |
||
185 | */ |
||
186 | View Code Duplication | public function push($parameters = [], $fetch = self::FETCH_OBJECT) |
|
201 | |||
202 | /** |
||
203 | * Tag the image name into a repository. |
||
204 | * |
||
205 | * @param array $parameters List of parameters |
||
206 | * |
||
207 | * (string)repo: The repository to tag in. |
||
208 | * (string)force: 1/True/true or 0/False/false, default false |
||
209 | * (string)tag: The new tag name. |
||
210 | * @param string $fetch Fetch mode (object or response) |
||
211 | * |
||
212 | * @return \Psr\Http\Message\ResponseInterface |
||
213 | */ |
||
214 | View Code Duplication | public function tag($parameters = [], $fetch = self::FETCH_OBJECT) |
|
229 | |||
230 | /** |
||
231 | * Remove the image name from the filesystem. |
||
232 | * |
||
233 | * @param array $parameters List of parameters |
||
234 | * |
||
235 | * (string)force: 1/True/true or 0/False/false, default false |
||
236 | * (string)noprune: 1/True/true or 0/False/false, default false. |
||
237 | * @param string $fetch Fetch mode (object or response) |
||
238 | * |
||
239 | * @return \Psr\Http\Message\ResponseInterface |
||
240 | */ |
||
241 | View Code Duplication | public function remove($parameters = [], $fetch = self::FETCH_OBJECT) |
|
255 | |||
256 | /** |
||
257 | * Search for an image on Docker Hub. |
||
258 | * |
||
259 | * @param array $parameters List of parameters |
||
260 | * |
||
261 | * (string)term: Term to search |
||
262 | * @param string $fetch Fetch mode (object or response) |
||
263 | * |
||
264 | * @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ImageSearchResult[] |
||
265 | */ |
||
266 | View Code Duplication | public function search($parameters = [], $fetch = self::FETCH_OBJECT) |
|
284 | |||
285 | /** |
||
286 | * Create a new image from a container’s changes. |
||
287 | * |
||
288 | * @param \Docker\API\Model\ContainerConfig $containerConfig The container configuration |
||
289 | * @param array $parameters List of parameters |
||
290 | * |
||
291 | * (string)container: Container id or name to commit |
||
292 | * (string)repo: Repository name for the created image |
||
293 | * (string)tag: Tag name for the create image |
||
294 | * (string)comment: Commit message |
||
295 | * (string)author: author (e.g., “John Hannibal Smith <[email protected]>“) |
||
296 | * (string)pause: 1/True/true or 0/False/false, whether to pause the container before committing |
||
297 | * (string)changes: Dockerfile instructions to apply while committing |
||
298 | * @param string $fetch Fetch mode (object or response) |
||
299 | * |
||
300 | * @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\CommitResult |
||
301 | */ |
||
302 | public function commit(\Docker\API\Model\ContainerConfig $containerConfig, $parameters = [], $fetch = self::FETCH_OBJECT) |
||
326 | |||
327 | /** |
||
328 | * Get a tarball containing all images and metadata for the repository specified by name. |
||
329 | * |
||
330 | * @param array $parameters List of parameters |
||
331 | * @param string $fetch Fetch mode (object or response) |
||
332 | * |
||
333 | * @return \Psr\Http\Message\ResponseInterface |
||
334 | */ |
||
335 | View Code Duplication | public function save($parameters = [], $fetch = self::FETCH_OBJECT) |
|
347 | |||
348 | /** |
||
349 | * Get a tarball containing all images and metadata for one or more repositories. |
||
350 | * |
||
351 | * @param array $parameters List of parameters |
||
352 | * |
||
353 | * (array)names: Image names to filter |
||
354 | * @param string $fetch Fetch mode (object or response) |
||
355 | * |
||
356 | * @return \Psr\Http\Message\ResponseInterface |
||
357 | */ |
||
358 | View Code Duplication | public function saveAll($parameters = [], $fetch = self::FETCH_OBJECT) |
|
371 | |||
372 | /** |
||
373 | * Load a set of images and tags into a Docker repository. See the image tarball format for more details. |
||
374 | * |
||
375 | * @param string $imagesTarball Tar archive containing images |
||
376 | * @param array $parameters List of parameters |
||
377 | * @param string $fetch Fetch mode (object or response) |
||
378 | * |
||
379 | * @return \Psr\Http\Message\ResponseInterface |
||
380 | */ |
||
381 | View Code Duplication | public function load(string $imagesTarball, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
393 | } |
||
394 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.