Conditions | 12 |
Paths | 2048 |
Total Lines | 74 |
Code Lines | 38 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
104 | public function text() { |
||
105 | |||
106 | $vcard = $this->prepareCard( $this->vcard ); |
||
107 | |||
108 | $text = "BEGIN:VCARD\r\n"; |
||
109 | $text .= "VERSION:3.0\r\n"; |
||
110 | |||
111 | // N and FN are required properties in vCard 3.0, we need to write something there |
||
112 | $text .= "N;CHARSET=UTF-8:" . |
||
113 | $vcard['lastname'] . ';' . |
||
114 | $vcard['firstname'] . ';' . |
||
115 | $vcard['additionalname'] . ';' . |
||
116 | $vcard['prefix'] . ';' . |
||
117 | $vcard['suffix'] . "\r\n"; |
||
118 | |||
119 | $text .= "FN;CHARSET=UTF-8:" . |
||
120 | $vcard['label'] . "\r\n"; |
||
121 | |||
122 | $text .= ( $this->isPublic ? 'CLASS:PUBLIC':'CLASS:CONFIDENTIAL' ) . "\r\n"; |
||
123 | |||
124 | if ( $vcard['birthday'] !== "" ) { |
||
125 | $text .= "BDAY:" . $vcard['birthday'] ."\r\n"; |
||
126 | } |
||
127 | |||
128 | if ( $vcard['title'] !== "" ) { |
||
129 | $text .= "TITLE;CHARSET=UTF-8:" . $vcard['title'] ."\r\n"; |
||
130 | } |
||
131 | |||
132 | if ( $vcard['role'] !== "" ) { |
||
133 | $text .= "ROLE;CHARSET=UTF-8:" . $vcard['role'] ."\r\n"; |
||
134 | } |
||
135 | |||
136 | if ( $vcard['organization'] !== "" ) { |
||
137 | $text .= "ORG;CHARSET=UTF-8:" . $vcard['organization'] . ';' . $vcard['department'] ."\r\n"; |
||
138 | } |
||
139 | |||
140 | if ( $vcard['category'] !== "" ) { |
||
141 | $text .= "CATEGORIES;CHARSET=UTF-8:" . $vcard['category'] ."\r\n"; |
||
142 | } |
||
143 | |||
144 | foreach ( $vcard['email'] as $e ) { |
||
145 | $text .= $e->text(); |
||
146 | } |
||
147 | |||
148 | foreach ( $vcard['address'] as $a ) { |
||
149 | $text .= $a->text(); |
||
150 | } |
||
151 | |||
152 | foreach ( $vcard['tel'] as $t ) { |
||
153 | $text .= $t->text(); |
||
154 | } |
||
155 | |||
156 | if ( $vcard['note'] !== "" ) { |
||
157 | $text .= "NOTE;CHARSET=UTF-8:" . $vcard['note'] ."\r\n"; |
||
158 | } |
||
159 | |||
160 | $text .= "SOURCE;CHARSET=UTF-8:$this->uri\r\n"; |
||
161 | |||
162 | // The identifier for the product that created the vCard object |
||
163 | $text .= "PRODID:-////Semantic MediaWiki\r\n"; |
||
164 | |||
165 | // A timestamp for the last time the vCard was updated |
||
166 | $text .= "REV:$this->timestamp\r\n"; |
||
167 | |||
168 | // A URL pointing to a website that represents the person in some way |
||
169 | $text .= "URL:" . ( $vcard['url'] !== "" ? $vcard['url'] : $this->uri ) . "\r\n"; |
||
170 | |||
171 | // Specifies a value that represents a persistent, globally unique |
||
172 | // identifier associated with the object. |
||
173 | $text .= "UID:$this->uri\r\n"; |
||
174 | $text .= "END:VCARD\r\n"; |
||
175 | |||
176 | return $text; |
||
177 | } |
||
178 | |||
239 |
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..