CableTv   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A getTvPackages() 4 4 1
A verifyCustomerID() 7 7 1
A purchasePackage() 11 11 2

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
 * Created By: Henry Ejemuta
4
 * PC: Enrico Systems
5
 * Project: laravel-clubkonnect
6
 * Company: Stimolive Technologies Limited
7
 * Class Name: Transaction.php
8
 * Date Created: 5/14/21
9
 * Time Created: 10:24 AM
10
 */
11
12
namespace HenryEjemuta\LaravelClubKonnect;
13
14
use HenryEjemuta\LaravelClubKonnect\Classes\ClubKonnectResponse;
15
use HenryEjemuta\LaravelClubKonnect\Enums\CableTvEnum;
16
use HenryEjemuta\LaravelClubKonnect\Exceptions\ClubKonnectErrorException;
17
18 View Code Duplication
abstract class CableTv
0 ignored issues
show
Duplication introduced by
This class 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...
19
{
20
    private $config;
21
    private $clubKonnect;
22
23
    public function __construct(ClubKonnect $clubKonnect, $config)
24
    {
25
        $this->config = $config;
26
        $this->clubKonnect = $clubKonnect;
27
    }
28
29
    /**
30
     * @return ClubKonnectResponse
31
     */
32
    public function getTvPackages(): ClubKonnectResponse
33
    {
34
        return $this->clubKonnect->withAuth('APICableTVPackagesV2.asp', []);
35
    }
36
37
    /**
38
     * @param CableTvEnum $cableTv
39
     * @param $smartCardNo
40
     * @return ClubKonnectResponse
41
     */
42
    public function verifyCustomerID(CableTvEnum $cableTv, $smartCardNo): ClubKonnectResponse
43
    {
44
        return $this->clubKonnect->withAuth('APIVerifyCableTVV1.0.asp', [
45
            'CableTV' => $cableTv->getCode(),
46
            'SmartCardNo' => $smartCardNo,
47
        ]);
48
    }
49
50
    /**
51
     * @param CableTvEnum $cableTv
52
     * @param string $package
53
     * @param $smartCardNo
54
     * @param $requestID
55
     * @param $callbackUrl
56
     * @return ClubKonnectResponse
57
     */
58
    public function purchasePackage(CableTvEnum $cableTv, string $package, $smartCardNo, $requestID, $callbackUrl = null): ClubKonnectResponse
59
    {
60
        $callbackUrl = is_null($callbackUrl) ? $this->config['default_redirect_url'] : $callbackUrl;
61
        return $this->clubKonnect->withAuth('APICableTVV1.asp', [
62
            'CableTV' => $cableTv->getCode(),
63
            'MeterType' => $package,
64
            'SmartCardNo' => $smartCardNo,
65
            'RequestID' => $requestID,
66
            'CallBackURL' => $callbackUrl
67
        ]);
68
    }
69
70
71
72
73
}
74