Completed
Push — master ( a72aaa...aa1c76 )
by Brian
03:39
created

ChannelHangupRequest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 60
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 71.43%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 2
dl 60
loc 60
ccs 10
cts 14
cp 0.7143
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getCause() 4 4 1
A getChannel() 4 4 1
A getSoft() 4 4 1
A getEventId() 4 4 1
A __construct() 8 8 3

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 2014 Brian Smith <[email protected]>.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *      http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace phparia\Events;
20
21
use phparia\Client\AriClient;
22
use phparia\Resources\Channel;
23
24
/**
25
 * A hangup was requested on the channel.
26
 *
27
 * @author Brian Smith <[email protected]>
28
 * @todo Add cause constants
29
 */
30 View Code Duplication
class ChannelHangupRequest extends Event implements IdentifiableEventInterface
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...
31
{
32
    /**
33
     * @var int (optional) - Integer representation of the cause of the hangup.
34
     */
35
    private $cause;
36
37
    /**
38
     * @var \phparia\Resources\Channel The channel on which the hangup was requested.
39
     */
40
    private $channel;
41
42
    /**
43
     * @var boolean (optional) - Whether the hangup request was a soft hangup request.
44
     */
45
    private $soft;
46
47
    /**
48
     * @return int
49
     */
50
    public function getCause()
51
    {
52
        return $this->cause;
53
    }
54
55
    /**
56
     * @return Channel
57
     */
58 1
    public function getChannel()
59
    {
60 1
        return $this->channel;
61
    }
62
63
    /**
64
     * @return boolean
65
     */
66
    public function getSoft()
67
    {
68
        return $this->soft;
69
    }
70
71 1
    public function getEventId()
72
    {
73 1
        return "{$this->getType()}_{$this->getChannel()->getId()}";
74
    }
75
76
    /**
77
     * @param AriClient $client
78
     * @param string $response
79
     */
80 1
    public function __construct(AriClient $client, $response)
81
    {
82 1
        parent::__construct($client, $response);
83
84 1
        $this->cause = property_exists($this->response, 'cause') ? $this->response->cause : null;
85 1
        $this->channel = new Channel($client, $this->response->channel);
86 1
        $this->soft = property_exists($this->response, 'soft') ? $this->response->soft : null;
87 1
    }
88
89
}
90