Peer   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 83
Duplicated Lines 12.05 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 10
loc 83
ccs 0
cts 29
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getAddress() 0 4 1
A getCause() 0 4 1
A getPeerStatus() 0 4 1
A getPort() 0 4 1
A getTime() 0 4 1
A __construct() 10 10 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
/*
4
 * Copyright 2017 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\Resources;
20
21
use phparia\Client\AriClient;
22
use phparia\Events\Event;
23
24
/**
25
 * Detailed information about a remote peer that communicates with Asterisk.
26
 *
27
 * @author Eric Smith <[email protected]>
28
 */
29
class Peer extends Resource
30
{
31
    /**
32
     * @var string (optional) - The IP address of the peer.
33
     */
34
    private $address;
35
36
    /**
37
     * @var string (optional) - An optional reason associated with the change in peer_status.
38
     */
39
    private $cause;
40
41
    /**
42
     * @var string The current state of the peer. Note that the values of the status are dependent on the underlying peer technology.
43
     */
44
    private $peerStatus;
45
46
    /**
47
     * @var string (optional) - The port of the peer.
48
     */
49
    private $port;
50
51
    /**
52
     * @var integer (optional) - The last known time the peer was contacted.
53
     */
54
    private $time;
55
56
    /**
57
     * @return string (optional) - The IP address of the peer.
58
     */
59
    public function getAddress()
60
    {
61
        return $this->address;
62
    }
63
64
    /**
65
     * @return string (optional) - An optional reason associated with the change in peer_status.
66
     */
67
    public function getCause()
68
    {
69
        return $this->cause;
70
    }
71
72
    /**
73
     * @return string The current state of the peer. Note that the values of the status are dependent on the underlying peer technology.
74
     */
75
    public function getPeerStatus()
76
    {
77
        return $this->peerStatus;
78
    }
79
80
    /**
81
     * @return string (optional) - The port of the peer.
82
     */
83
    public function getPort()
84
    {
85
        return $this->port;
86
    }
87
88
    /**
89
     * @return integer (optional) - The last known time the peer was contacted.
90
     */
91
    public function getTime()
92
    {
93
        return $this->time;
94
    }
95
96
    /**
97
     * @param AriClient $client
98
     * @param string $response
99
     */
100 View Code Duplication
    public function __construct(AriClient $client, $response)
101
    {
102
        parent::__construct($client, $response);
103
104
        $this->address = $this->getResponseValue('address');
105
        $this->cause = $this->getResponseValue('cause');
106
        $this->peerStatus = $this->getResponseValue('peer_status');
107
        $this->port = $this->getResponseValue('port');
108
        $this->time = $this->getResponseValue('time');
109
    }
110
111
}
112