Completed
Push — master ( bb3faf...1c3da6 )
by Ibrahim
13:51
created

Subscription   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 125
Duplicated Lines 12.8 %

Coupling/Cohesion

Components 1
Dependencies 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 16
loc 125
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A root() 0 4 1
A create() 0 10 1
A fetch() 0 6 1
A getList() 0 5 1
A disable() 8 8 1
A enable() 8 8 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
namespace Yabacon\Paystack\Routes;
4
5
use Yabacon\Paystack\Contracts\RouteInterface;
6
7
/**
8
 * Subscription
9
 * Insert description here
10
 *
11
 * @category
12
 * @package
13
 * @author
14
 * @copyright
15
 * @license
16
 * @version
17
 * @link
18
 * @see
19
 * @since
20
 */
21
class Subscription implements RouteInterface
22
{
23
24
    /**
25
      Root
26
     */
27
    public static function root()
28
    {
29
        return '/subscription';
30
    }
31
    /*
32
      Create subscription
33
     */
34
35
    /**
36
     * create
37
     * Insert description here
38
     *
39
     * @return
40
     *
41
     * @access
42
     * @static
43
     * @see
44
     * @since
45
     */
46
    public static function create()
47
    {
48
        return [RouteInterface::METHOD_KEY   => RouteInterface::POST_METHOD,
49
            RouteInterface::ENDPOINT_KEY => Subscription::root(),
50
            RouteInterface::PARAMS_KEY   => [
51
                'customer',
52
                'plan',
53
                'authorization' ]
54
        ];
55
    }
56
    /*
57
      Get subscription
58
     */
59
60
    /**
61
     * fetch
62
     * Insert description here
63
     *
64
     * @return
65
     *
66
     * @access
67
     * @static
68
     * @see
69
     * @since
70
     */
71
    public static function fetch()
72
    {
73
        return [RouteInterface::METHOD_KEY   => RouteInterface::GET_METHOD,
74
            RouteInterface::ENDPOINT_KEY => Subscription::root() . '/{id}',
75
            RouteInterface::ARGS_KEY     => ['id' ] ];
76
    }
77
78
    /*
79
      List subscription
80
     */
81
82
    /**
83
     * getList
84
     * Insert description here
85
     *
86
     * @return
87
     *
88
     * @access
89
     * @static
90
     * @see
91
     * @since
92
     */
93
    public static function getList()
94
    {
95
        return [RouteInterface::METHOD_KEY   => RouteInterface::GET_METHOD,
96
            RouteInterface::ENDPOINT_KEY => Subscription::root() ];
97
    }
98
    /*
99
      Disable subscription
100
     */
101
102
    /**
103
     * disable
104
     * Insert description here
105
     *
106
     * @return
107
     *
108
     * @access
109
     * @static
110
     * @see
111
     * @since
112
     */
113 View Code Duplication
    public static function disable()
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...
114
    {
115
        return [RouteInterface::METHOD_KEY   => RouteInterface::POST_METHOD,
116
            RouteInterface::ENDPOINT_KEY => Subscription::root(). '/disable',
117
            RouteInterface::PARAMS_KEY   => [
118
                'code',
119
                'token'] ];
120
    }
121
    
122
    /*
123
      Enable subscription
124
     */
125
126
    /**
127
     * enable
128
     * Insert description here
129
     *
130
     * @return
131
     *
132
     * @access
133
     * @static
134
     * @see
135
     * @since
136
     */
137 View Code Duplication
    public static function enable()
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...
138
    {
139
        return [RouteInterface::METHOD_KEY   => RouteInterface::POST_METHOD,
140
            RouteInterface::ENDPOINT_KEY => Subscription::root() . '/enable',
141
            RouteInterface::PARAMS_KEY   => [
142
                'code',
143
                'token'] ];
144
    }
145
}
146