VCard::setLastname()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Fabiang\Xmpp\Protocol;
4
5
use Fabiang\Xmpp\Util\XML;
6
7
/**
8
 * Protocol setting for Xmpp.
9
 *
10
 * @package Xmpp\Protocol
11
 */
12
class VCard implements ProtocolImplementationInterface
13
{
14
15
    /**
16
     * vCard to.
17
     *
18
     * @var string|null
19
     */
20
    protected $to;
21
22
23
    /**
24
     * user firstname.
25
     *
26
     * @var string
27
     */
28
    protected $firstname;
29
30
    /**
31
     * user lastname.
32
     *
33
     * @var string
34
     */
35
    protected $lastname;
36
37
    protected $jabberid;
38
39
    protected $mime;
40
41
    protected $image;
42
43
    protected $ulr;
44
45
    /**
46
     * Constructor.
47
     *
48
     * @param integer $priority
0 ignored issues
show
Bug introduced by
There is no parameter named $priority. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
49
     * @param string $to
0 ignored issues
show
Bug introduced by
There is no parameter named $to. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
50
     * @param string $nickname
0 ignored issues
show
Bug introduced by
There is no parameter named $nickname. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
51
     */
52
    public function __construct($firstname = null, $lastname = null,  $jabberid = null)
0 ignored issues
show
Coding Style introduced by
Expected 1 space between comma and argument "$jabberid"; 2 found
Loading history...
53
    {
54
        $this->setFirstname($firstname);
55
        $this->setLastname($lastname);
56
        $this->setJabberID($jabberid);
57
    }
58
59
    /**
60
     * {@inheritDoc}
61
     */
62
    public function toString()
63
    {
64
65
         return XML::quoteMessage(
66
            '<iq id="' . XML::generateId() . '" type="set">
67
              <vCard xmlns="vcard-temp">
68
                <FN>%s</FN>
69
                <N>
70
                  <FAMILY>%s</FAMILY>
71
                  <GIVEN>%s</GIVEN>
72
                  <MIDDLE/>
73
                </N>
74
                <NICKNAME>%s</NICKNAME>
75
                <URL>%s</URL>
76
                <PHOTO>
77
                  <TYPE>%s</TYPE>
78
                  <BINVAL>
79
                    %s
80
                  </BINVAL>
81
                </PHOTO>
82
                <JABBERID>%s</JABBERID>
83
                <DESC/>
84
              </vCard>
85
            </iq>',
86
            $this->getFirstname().' '.$this->getLastname(),
87
            $this->getLastname(),
88
            $this->getFirstname(),
89
            $this->getFirstname().' '.$this->getLastname(),
90
            $this->getUrl(),
91
            $this->getMime(),
92
            $this->getImage(),
93
            $this->getJabberID()
94
        );
95
    }
96
97
    /**
98
     * Get nickname.
99
     *
100
     * @return string
101
     */
102
    public function getFirstname()
103
    {
104
        return $this->firstname;
105
    }
106
107
    /**
108
     * Set nickname.
109
     *
110
     * @param string $nickname
0 ignored issues
show
Bug introduced by
There is no parameter named $nickname. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
111
     * @return $this
112
     */
113
    public function setFirstname($firstname)
114
    {
115
        $this->firstname = (string) $firstname;
116
        return $this;
117
    }
118
119
    /**
120
     * Get nickname.
121
     *
122
     * @return string
123
     */
124
    public function getLastname()
125
    {
126
        return $this->lastname;
127
    }
128
129
    /**
130
     * Set nickname.
131
     *
132
     * @param string $nickname
0 ignored issues
show
Bug introduced by
There is no parameter named $nickname. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
133
     * @return $this
134
     */
135
    public function setLastname($lastname)
136
    {
137
        $this->lastname = (string) $lastname;
138
        return $this;
139
    }
140
141
    /**
142
     * Get JabberID.
143
     *
144
     * @return string
145
     */
146
    public function getJabberID()
147
    {
148
        return $this->jabberid;
149
    }
150
151
    /**
152
     * Set abberID.
153
     *
154
     * @param string $nickname
0 ignored issues
show
Bug introduced by
There is no parameter named $nickname. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
155
     * @return $this
156
     */
157
    public function setJabberID($jabberid)
158
    {
159
        $this->jabberid = (string) $jabberid;
160
        return $this;
161
    }
162
163
    /**
164
     * Get mime.
165
     *
166
     * @return string
167
     */
168
    public function getMime()
169
    {
170
        return $this->mime;
171
    }
172
173
    /**
174
     * Set mime.
175
     *
176
     * @param string $mime
177
     * @return $this
178
     */
179
    public function setMime($mime)
180
    {
181
        $this->mime = (string) $mime;
182
        return $this;
183
    }
184
185
    /**
186
     * Get image.
187
     *
188
     * @return string
189
     */
190
    public function getImage()
191
    {
192
        return $this->image;
193
    }
194
195
    /**
196
     * Set image.
197
     *
198
     * @param string $image base64
199
     * @return $this
200
     */
201
    public function setImage($image)
202
    {
203
        $this->image = (string) $image;
204
        return $this;
205
    }
206
207
    /**
208
     * Get url.
209
     *
210
     * @return string
211
     */
212
    public function getUrl()
213
    {
214
        return $this->url;
0 ignored issues
show
Bug introduced by
The property url 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...
215
    }
216
217
    /**
218
     * Set url.
219
     *
220
     * @param string $image base64
0 ignored issues
show
Bug introduced by
There is no parameter named $image. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
221
     * @return $this
222
     */
223
    public function setUrl($url)
224
    {
225
        $this->url = (string) $url;
226
        return $this;
227
    }
228
}
229