TextMessage   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 68
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 68
loc 68
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getBody() 4 4 1
A getFrom() 4 4 1
A getTo() 4 4 1
A getVariables() 4 4 1
A __construct() 9 9 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 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\Resources;
20
21
/**
22
 * A text message.
23
 *
24
 * @author Brian Smith <[email protected]>
25
 */
26 View Code Duplication
class TextMessage extends Response
27
{
28
    /**
29
     * @var string The text of the message.
30
     */
31
    private $body;
32
33
    /**
34
     * @var string A technology specific URI specifying the source of the message. For sip and pjsip technologies, any SIP URI can be specified. For xmpp, the URI must correspond to the client connection being used to send the message.
35
     */
36
    private $from;
37
38
    /**
39
     * @var string A technology specific URI specifying the destination of the message. Valid technologies include sip, pjsip, and xmp. The destination of a message should be an endpoint.
40
     */
41
    private $to;
42
43
    /**
44
     * @var array (optional) - Technology specific key/value pairs associated with the message.
45
     */
46
    private $variables;
47
48
    /**
49
     * @return string The text of the message.
50
     */
51
    public function getBody()
52
    {
53
        return $this->body;
54
    }
55
56
    /**
57
     * @return string A technology specific URI specifying the source of the message. For sip and pjsip technologies, any SIP URI can be specified. For xmpp, the URI must correspond to the client connection being used to send the message.
58
     */
59
    public function getFrom()
60
    {
61
        return $this->from;
62
    }
63
64
    /**
65
     * @return string A technology specific URI specifying the destination of the message. Valid technologies include sip, pjsip, and xmp. The destination of a message should be an endpoint.
66
     */
67
    public function getTo()
68
    {
69
        return $this->to;
70
    }
71
72
    /**
73
     * @return TextMessageVariable[] (optional) - Technology specific key/value pairs associated with the message.
74
     */
75
    public function getVariables()
76
    {
77
        return $this->variables;
78
    }
79
80
    /**
81
     * @param string $response
82
     */
83
    public function __construct($response)
84
    {
85
        parent::__construct($response);
86
87
        $this->body = $this->getResponseValue('body');
88
        $this->from = $this->getResponseValue('from');
89
        $this->to = $this->getResponseValue('to');
90
        $this->variables = $this->getResponseValue('variables');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getResponseValue('variables') of type * is incompatible with the declared type array of property $variables.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
91
    }
92
93
}
94