Completed
Pull Request — master (#249)
by David
08:52
created

Routes   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 80
Duplicated Lines 17.5 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 14
loc 80
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 14 14 1
A show() 0 9 1
A create() 0 3 1
A update() 0 3 1
A delete() 0 3 1

How to fix   Duplicated Code   

Duplicated Code

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
2
3
/*
4
 * Copyright (C) 2013-2016 Mailgun
5
 *
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license. See the LICENSE file for details.
8
 */
9
10
namespace Mailgun\Api;
11
12
use Mailgun\Assert;
13
use Mailgun\Resource\Api\Routes\Dto\RouteDto;
14
use Mailgun\Resource\Api\Routes\Response\IndexResponse;
15
use Mailgun\Resource\Api\Routes\Response\ShowResponse;
16
17
/**
18
 * {@link https://documentation.mailgun.com/api-routes.html}.
19
 *
20
 * @author David Garcia <[email protected]>
21
 */
22
class Routes extends HttpApi
23
{
24
    /**
25
     * Fetches the list of Routes. Note that Routes are defined globally,
26
     * per account, not per domain as most of other API calls.
27
     *
28
     * @param int $limit Maximum number of records to return. (100 by default)
29
     * @param int $skip  Number of records to skip. (0 by default)
30
     *
31
     * @return IndexResponse
32
     */
33 View Code Duplication
    public function index($limit = 100, $skip = 0)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        Assert::integer($limit);
36
        Assert::integer($skip);
37
38
        $params = [
39
            'limit' => $limit,
40
            'skip' => $skip,
41
        ];
42
43
        $response = $this->httpGet('/v3/routes', $params);
44
45
        return $this->safeDeserialize($response, IndexResponse::class);
46
    }
47
48
    /**
49
     * Returns a single Route object based on its ID.
50
     *
51
     * @param string $routeId Route ID returned by the Routes::index() method
52
     *
53
     * @return RouteDto
54
     */
55
    public function show($routeId)
56
    {
57
        Assert::notEmpty($routeId);
58
        Assert::string($routeId);
59
60
        $response = $this->httpGet(sprintf('/v3/routes/%s', $routeId));
61
62
        return $this->safeDeserialize($response, ShowResponse::class);
63
    }
64
65
    /**
66
     * Creates a new Route.
67
     *
68
     * @param string $expression  A filter expression like "match_recipient('.*@gmail.com')"
69
     * @param array  $actions     Route action. This action is executed when the expression evaluates to True. Example: "forward('[email protected]')"
70
     * @param string $description An arbitrary string
71
     * @param int    $priority    Integer: smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0.
72
     *
73
     * @return
74
     */
75
    public function create($expression, array $actions, $description, $priority = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $expression is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $actions is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $description is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $priority is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
76
    {
77
    }
78
79
    /**
80
     * Updates a given Route by ID. All parameters are optional.
81
     * This API call only updates the specified fields leaving others unchanged.
82
     *
83
     * @param string      $routeId     Route ID returned by the Routes::index() method
84
     * @param string|null $expression  A filter expression like "match_recipient('.*@gmail.com')"
85
     * @param array|null  $actions     Route action. This action is executed when the expression evaluates to True. Example: "forward('[email protected]')"
86
     * @param string|null $description An arbitrary string
87
     * @param int|null    $priority    Integer: smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0.
88
     *
89
     * @return
90
     */
91
    public function update($routeId, $expression = null, array $actions = null, $description = null, $priority = null)
0 ignored issues
show
Unused Code introduced by
The parameter $routeId is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $expression is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $actions is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $description is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $priority is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
92
    {
93
    }
94
95
    /**
96
     * Deletes a Route based on the ID.
97
     */
98
    public function delete()
99
    {
100
    }
101
}
102