Completed
Push — master ( 58043b...413e7c )
by Sergi Tur
06:39
created

ProgressBarStatusHasBeenUpdated   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 71
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 71
loc 71
rs 10
c 1
b 0
f 0
wmc 4
lcom 1
cbo 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getChannelName() 4 4 1
A setChannelName() 4 4 1
A __construct() 6 6 1
A broadcastOn() 4 4 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 Acacha\Users\Events;
4
5
use Illuminate\Broadcasting\Channel;
6
use Illuminate\Queue\SerializesModels;
7
use Illuminate\Foundation\Events\Dispatchable;
8
use Illuminate\Broadcasting\InteractsWithSockets;
9
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
10
11
/**
12
 * Class ProgressBarStatusHasBeenUpdated
13
 *
14
 * @package Acacha\Users\Events
15
 */
16 View Code Duplication
class ProgressBarStatusHasBeenUpdated implements ShouldBroadcast
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...
17
{
18
    use Dispatchable, InteractsWithSockets, SerializesModels;
19
20
    /**
21
     * Id of progress bar to update.
22
     *
23
     * @var
24
     */
25
    public $id;
26
27
    /**
28
     * Current progress var value.
29
     *
30
     * @var
31
     */
32
    public $progress;
33
34
    /**
35
     * Message to show in progress bar.
36
     *
37
     * @var
38
     */
39
    public $message;
40
41
    /**
42
     * Broadcast channel name.
43
     *
44
     * @var string
45
     */
46
    protected $channelName = 'progress-bar';
47
48
    /**
49
     * @return string
50
     */
51
    public function getChannelName()
52
    {
53
        return $this->channelName;
54
    }
55
56
    /**
57
     * @param string $channelName
58
     */
59
    public function setChannelName($channelName)
60
    {
61
        $this->channelName = $channelName;
62
    }
63
64
    /**
65
     * ProgressBarStatusHasBeenUpdated constructor.
66
     *
67
     * @param $progress
68
     * @param $message
69
     */
70
    public function __construct($id, $progress, $message)
71
    {
72
        $this->id = $id;
73
        $this->progress = $progress;
74
        $this->message = $message;
75
    }
76
77
    /**
78
     * Get the channels the event should broadcast on.
79
     *
80
     * @return Channel|array
81
     */
82
    public function broadcastOn()
83
    {
84
        return new Channel($this->channelName);
85
    }
86
}
87