GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( e3718d...6a7df8 )
by Lester
01:14
created

TransferAirtime   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A handle() 4 4 1
A topup() 6 6 1
A setService() 6 6 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 LBHurtado\EngageSpark\Jobs;
4
5
use Illuminate\Bus\Queueable;
6
use LBHurtado\EngageSpark\EngageSpark;
7
use Illuminate\Queue\SerializesModels;
8
use Illuminate\Queue\InteractsWithQueue;
9
use Illuminate\Contracts\Queue\ShouldQueue;
10
use Illuminate\Foundation\Bus\Dispatchable;
11
use LBHurtado\EngageSpark\Classes\ServiceMode;
12
use  LBHurtado\EngageSpark\Classes\TopupHttpApiParams;
13
14 View Code Duplication
class TransferAirtime implements ShouldQueue
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...
15
{
16
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
17
18
    const MODE = 'topup';
19
20
    /** @var string */
21
    public $mobile;
22
23
    /** @var int */
24
    public $amount;
25
26
    /** @var string */
27
    public $reference;
28
29
    /**
30
     * TopupAmount constructor.
31
     * @param string $mobile
32
     * @param int $amount
33
     * @param string $reference
34
     */
35
    public function __construct(string $mobile, int $amount, string $reference)
36
    {
37
        $this->mobile = $mobile;
38
        $this->amount = $amount;
39
        $this->reference = $reference;
40
    }
41
42
    /**
43
     * @param EngageSpark $service
44
     * @throws \GuzzleHttp\Exception\GuzzleException
45
     */
46
    public function handle(EngageSpark $service)
47
    {
48
        $this->setService($service)->topup();
49
    }
50
51
    protected function topup()
52
    {
53
        tap(new TopupHttpApiParams($this->service, $this->mobile, $this->amount, $this->reference), function ($params) {
0 ignored issues
show
Bug introduced by
The property service does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
54
            $this->service->send($params->toArray(), ServiceMode::TOPUP);    
55
        });
56
    }
57
58
    protected function setService(EngageSpark $service)
59
    {
60
        $this->service = $service;
61
62
        return $this;
63
    }
64
}
65