| @@ -6,8 +6,8 @@ discard block | ||
| 6 | 6 | * @author Jeroen Desloovere <[email protected]> | 
| 7 | 7 | */ | 
| 8 | 8 | |
| 9 | -require_once __DIR__ . '/../vendor/autoload.php'; | |
| 10 | -require_once __DIR__ . '/../src/VCard.php'; | |
| 9 | +require_once __DIR__.'/../vendor/autoload.php'; | |
| 10 | +require_once __DIR__.'/../src/VCard.php'; | |
| 11 | 11 | |
| 12 | 12 | use JeroenDesloovere\VCard\VCard; | 
| 13 | 13 | |
| @@ -33,7 +33,7 @@ discard block | ||
| 33 | 33 | $vcard->addAddress(null, null, 'street', 'worktown', null, 'workpostcode', 'Belgium'); | 
| 34 | 34 |  $vcard->addURL('http://www.jeroendesloovere.be'); | 
| 35 | 35 | |
| 36 | -$vcard->addPhoto(__DIR__ . '/assets/landscape.jpeg'); | |
| 36 | +$vcard->addPhoto(__DIR__.'/assets/landscape.jpeg'); | |
| 37 | 37 | |
| 38 | 38 | // return vcard as a string | 
| 39 | 39 | //return $vcard->getOutput(); | 
| @@ -42,7 +42,7 @@ discard block | ||
| 42 | 42 | return $vcard->download(); | 
| 43 | 43 | |
| 44 | 44 | // echo message | 
| 45 | -echo 'A personal vCard is saved in this folder: ' . __DIR__; | |
| 45 | +echo 'A personal vCard is saved in this folder: '.__DIR__; | |
| 46 | 46 | |
| 47 | 47 | // or | 
| 48 | 48 | |
| @@ -54,7 +54,7 @@ discard block | ||
| 54 | 54 | * | 
| 55 | 55 | * @param string $filename | 
| 56 | 56 | * | 
| 57 | - * @return JeroenDesloovere\VCard\VCardParser | |
| 57 | + * @return VCardParser | |
| 58 | 58 | */ | 
| 59 | 59 | public static function parseFromFile($filename) | 
| 60 | 60 |      { | 
| @@ -65,6 +65,9 @@ discard block | ||
| 65 | 65 | } | 
| 66 | 66 | } | 
| 67 | 67 | |
| 68 | + /** | |
| 69 | + * @param string $content | |
| 70 | + */ | |
| 68 | 71 | public function __construct($content) | 
| 69 | 72 |      { | 
| 70 | 73 | $this->content = $content; | 
| @@ -37,7 +37,7 @@ | ||
| 37 | 37 | |
| 38 | 38 | /** | 
| 39 | 39 | * The raw VCard content. | 
| 40 | - * | |
| 40 | + * | |
| 41 | 41 | * @var string | 
| 42 | 42 | */ | 
| 43 | 43 | protected $content; | 
| @@ -154,7 +154,7 @@ | ||
| 154 | 154 | $cardData->fullname = $value; | 
| 155 | 155 | break; | 
| 156 | 156 | case 'N': | 
| 157 | -                        foreach($this->parseName($value) as $key => $val) { | |
| 157 | +                        foreach ($this->parseName($value) as $key => $val) { | |
| 158 | 158 |                              $cardData->{$key} = $val; | 
| 159 | 159 | } | 
| 160 | 160 | break; | 
| @@ -84,12 +84,12 @@ discard block | ||
| 84 | 84 | $type = 'WORK;POSTAL' | 
| 85 | 85 |      ) { | 
| 86 | 86 | // init value | 
| 87 | - $value = $name . ';' . $extended . ';' . $street . ';' . $city . ';' . $region . ';' . $zip . ';' . $country; | |
| 87 | + $value = $name.';'.$extended.';'.$street.';'.$city.';'.$region.';'.$zip.';'.$country; | |
| 88 | 88 | |
| 89 | 89 | // set property | 
| 90 | 90 | $this->setProperty( | 
| 91 | 91 | 'address', | 
| 92 | - 'ADR' . (($type != '') ? ';' . $type : '') . $this->getCharsetString(), | |
| 92 | + 'ADR'.(($type != '') ? ';'.$type : '').$this->getCharsetString(), | |
| 93 | 93 | $value | 
| 94 | 94 | ); | 
| 95 | 95 | |
| @@ -123,7 +123,7 @@ discard block | ||
| 123 | 123 |      { | 
| 124 | 124 | $this->setProperty( | 
| 125 | 125 | 'company', | 
| 126 | - 'ORG' . $this->getCharsetString(), | |
| 126 | + 'ORG'.$this->getCharsetString(), | |
| 127 | 127 | $company | 
| 128 | 128 | ); | 
| 129 | 129 | |
| @@ -148,7 +148,7 @@ discard block | ||
| 148 | 148 |      { | 
| 149 | 149 | $this->setProperty( | 
| 150 | 150 | 'email', | 
| 151 | - 'EMAIL;INTERNET' . (($type != '') ? ';' . $type : ''), | |
| 151 | + 'EMAIL;INTERNET'.(($type != '') ? ';'.$type : ''), | |
| 152 | 152 | $address | 
| 153 | 153 | ); | 
| 154 | 154 | |
| @@ -165,7 +165,7 @@ discard block | ||
| 165 | 165 |      { | 
| 166 | 166 | $this->setProperty( | 
| 167 | 167 | 'jobtitle', | 
| 168 | - 'TITLE' . $this->getCharsetString(), | |
| 168 | + 'TITLE'.$this->getCharsetString(), | |
| 169 | 169 | $jobtitle | 
| 170 | 170 | ); | 
| 171 | 171 | |
| @@ -192,7 +192,7 @@ discard block | ||
| 192 | 192 | $value = base64_encode($value); | 
| 193 | 193 | |
| 194 | 194 | $finfo = finfo_open(FILEINFO_MIME_TYPE); | 
| 195 | - $mimetype = finfo_file($finfo, 'data://application/octet-stream;base64,' . $value); | |
| 195 | + $mimetype = finfo_file($finfo, 'data://application/octet-stream;base64,'.$value); | |
| 196 | 196 | finfo_close($finfo); | 
| 197 | 197 | |
| 198 | 198 |              if (preg_match('/^image\//', $mimetype) !== 1) { | 
| @@ -201,7 +201,7 @@ discard block | ||
| 201 | 201 | |
| 202 | 202 |              $type = strtoupper(str_replace('image/', '', $mimetype)); | 
| 203 | 203 | |
| 204 | - $property .= ";ENCODING=b;TYPE=" . $type; | |
| 204 | + $property .= ";ENCODING=b;TYPE=".$type; | |
| 205 | 205 |          } else { | 
| 206 | 206 |              if (filter_var($url, FILTER_VALIDATE_URL) !== FALSE) { | 
| 207 | 207 | $propertySuffix = ';VALUE=URL'; | 
| @@ -222,9 +222,9 @@ discard block | ||
| 222 | 222 |                      throw new VCardMediaException('Returned data isn\'t an image.'); | 
| 223 | 223 | } | 
| 224 | 224 | |
| 225 | - $propertySuffix .= ';TYPE=' . strtoupper($fileType); | |
| 225 | + $propertySuffix .= ';TYPE='.strtoupper($fileType); | |
| 226 | 226 | |
| 227 | - $property = $property . $propertySuffix; | |
| 227 | + $property = $property.$propertySuffix; | |
| 228 | 228 | $value = $url; | 
| 229 | 229 |              } else { | 
| 230 | 230 | $value = $url; | 
| @@ -268,10 +268,10 @@ discard block | ||
| 268 | 268 | $this->setFilename($values); | 
| 269 | 269 | |
| 270 | 270 | // set property | 
| 271 | - $property = $lastName . ';' . $firstName . ';' . $additional . ';' . $prefix . ';' . $suffix; | |
| 271 | + $property = $lastName.';'.$firstName.';'.$additional.';'.$prefix.';'.$suffix; | |
| 272 | 272 | $this->setProperty( | 
| 273 | 273 | 'name', | 
| 274 | - 'N' . $this->getCharsetString(), | |
| 274 | + 'N'.$this->getCharsetString(), | |
| 275 | 275 | $property | 
| 276 | 276 | ); | 
| 277 | 277 | |
| @@ -280,7 +280,7 @@ discard block | ||
| 280 | 280 | // set property | 
| 281 | 281 | $this->setProperty( | 
| 282 | 282 | 'fullname', | 
| 283 | - 'FN' . $this->getCharsetString(), | |
| 283 | + 'FN'.$this->getCharsetString(), | |
| 284 | 284 |                  trim(implode(' ', $values)) | 
| 285 | 285 | ); | 
| 286 | 286 | } | 
| @@ -298,7 +298,7 @@ discard block | ||
| 298 | 298 |      { | 
| 299 | 299 | $this->setProperty( | 
| 300 | 300 | 'note', | 
| 301 | - 'NOTE' . $this->getCharsetString(), | |
| 301 | + 'NOTE'.$this->getCharsetString(), | |
| 302 | 302 | $note | 
| 303 | 303 | ); | 
| 304 | 304 | |
| @@ -319,7 +319,7 @@ discard block | ||
| 319 | 319 |      { | 
| 320 | 320 | $this->setProperty( | 
| 321 | 321 | 'phoneNumber', | 
| 322 | - 'TEL' . (($type != '') ? ';' . $type : ''), | |
| 322 | + 'TEL'.(($type != '') ? ';'.$type : ''), | |
| 323 | 323 | $number | 
| 324 | 324 | ); | 
| 325 | 325 | |
| @@ -356,7 +356,7 @@ discard block | ||
| 356 | 356 |      { | 
| 357 | 357 | $this->setProperty( | 
| 358 | 358 | 'url', | 
| 359 | - 'URL' . (($type != '') ? ';' . $type : ''), | |
| 359 | + 'URL'.(($type != '') ? ';'.$type : ''), | |
| 360 | 360 | $url | 
| 361 | 361 | ); | 
| 362 | 362 | |
| @@ -373,13 +373,13 @@ discard block | ||
| 373 | 373 | // init string | 
| 374 | 374 | $string = "BEGIN:VCARD\r\n"; | 
| 375 | 375 | $string .= "VERSION:3.0\r\n"; | 
| 376 | -        $string .= "REV:" . date("Y-m-d") . "T" . date("H:i:s") . "Z\r\n"; | |
| 376 | +        $string .= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n"; | |
| 377 | 377 | |
| 378 | 378 | // loop all properties | 
| 379 | 379 | $properties = $this->getProperties(); | 
| 380 | 380 |          foreach ($properties as $property) { | 
| 381 | 381 | // add to string | 
| 382 | - $string .= $this->fold($property['key'] . ':' . $this->escape($property['value']) . "\r\n"); | |
| 382 | + $string .= $this->fold($property['key'].':'.$this->escape($property['value'])."\r\n"); | |
| 383 | 383 | } | 
| 384 | 384 | |
| 385 | 385 | // add to string | 
| @@ -397,19 +397,19 @@ discard block | ||
| 397 | 397 | public function buildVCalendar() | 
| 398 | 398 |      { | 
| 399 | 399 | // init dates | 
| 400 | -        $dtstart = date("Ymd") . "T" . date("Hi") . "00"; | |
| 401 | -        $dtend = date("Ymd") . "T" . date("Hi") . "01"; | |
| 400 | +        $dtstart = date("Ymd")."T".date("Hi")."00"; | |
| 401 | +        $dtend = date("Ymd")."T".date("Hi")."01"; | |
| 402 | 402 | |
| 403 | 403 | // init string | 
| 404 | 404 | $string = "BEGIN:VCALENDAR\n"; | 
| 405 | 405 | $string .= "VERSION:2.0\n"; | 
| 406 | 406 | $string .= "BEGIN:VEVENT\n"; | 
| 407 | - $string .= "DTSTART;TZID=Europe/London:" . $dtstart . "\n"; | |
| 408 | - $string .= "DTEND;TZID=Europe/London:" . $dtend . "\n"; | |
| 407 | + $string .= "DTSTART;TZID=Europe/London:".$dtstart."\n"; | |
| 408 | + $string .= "DTEND;TZID=Europe/London:".$dtend."\n"; | |
| 409 | 409 | $string .= "SUMMARY:Click attached contact below to save to your contacts\n"; | 
| 410 | - $string .= "DTSTAMP:" . $dtstart . "Z\n"; | |
| 410 | + $string .= "DTSTAMP:".$dtstart."Z\n"; | |
| 411 | 411 | $string .= "ATTACH;VALUE=BINARY;ENCODING=BASE64;FMTTYPE=text/directory;\n"; | 
| 412 | - $string .= " X-APPLE-FILENAME=" . $this->getFilename() . "." . $this->getFileExtension() . ":\n"; | |
| 412 | + $string .= " X-APPLE-FILENAME=".$this->getFilename().".".$this->getFileExtension().":\n"; | |
| 413 | 413 | |
| 414 | 414 | // base64 encode it so that it can be used as an attachemnt to the "dummy" calendar appointment | 
| 415 | 415 | $b64vcard = base64_encode($this->buildVCard()); | 
| @@ -536,7 +536,7 @@ discard block | ||
| 536 | 536 |      { | 
| 537 | 537 | $charsetString = ''; | 
| 538 | 538 |          if ($this->charset == 'utf-8') { | 
| 539 | - $charsetString = ';CHARSET=' . $this->charset; | |
| 539 | + $charsetString = ';CHARSET='.$this->charset; | |
| 540 | 540 | } | 
| 541 | 541 | return $charsetString; | 
| 542 | 542 | } | 
| @@ -581,8 +581,8 @@ discard block | ||
| 581 | 581 | */ | 
| 582 | 582 | public function getHeaders($asAssociative) | 
| 583 | 583 |      { | 
| 584 | - $contentType = $this->getContentType() . '; charset=' . $this->getCharset(); | |
| 585 | - $contentDisposition = 'attachment; filename=' . $this->getFilename() . '.' . $this->getFileExtension(); | |
| 584 | + $contentType = $this->getContentType().'; charset='.$this->getCharset(); | |
| 585 | + $contentDisposition = 'attachment; filename='.$this->getFilename().'.'.$this->getFileExtension(); | |
| 586 | 586 | $contentLength = strlen($this->getOutput()); | 
| 587 | 587 | $connection = 'close'; | 
| 588 | 588 | |
| @@ -596,10 +596,10 @@ discard block | ||
| 596 | 596 | } | 
| 597 | 597 | |
| 598 | 598 | return array( | 
| 599 | - 'Content-type: ' . $contentType, | |
| 600 | - 'Content-Disposition: ' . $contentDisposition, | |
| 601 | - 'Content-Length: ' . $contentLength, | |
| 602 | - 'Connection: ' . $connection, | |
| 599 | + 'Content-type: '.$contentType, | |
| 600 | + 'Content-Disposition: '.$contentDisposition, | |
| 601 | + 'Content-Length: '.$contentLength, | |
| 602 | + 'Connection: '.$connection, | |
| 603 | 603 | ); | 
| 604 | 604 | } | 
| 605 | 605 | |
| @@ -677,7 +677,7 @@ discard block | ||
| 677 | 677 | */ | 
| 678 | 678 | public function save() | 
| 679 | 679 |      { | 
| 680 | - $file = $this->getFilename() . '.' . $this->getFileExtension(); | |
| 680 | + $file = $this->getFilename().'.'.$this->getFileExtension(); | |
| 681 | 681 | |
| 682 | 682 | file_put_contents( | 
| 683 | 683 | $file, | 
| @@ -730,7 +730,7 @@ discard block | ||
| 730 | 730 | |
| 731 | 731 | // overwrite filename or add to filename using a prefix in between | 
| 732 | 732 | $this->filename = ($overwrite) ? | 
| 733 | - $value : $this->filename . $separator . $value; | |
| 733 | + $value : $this->filename.$separator.$value; | |
| 734 | 734 | } | 
| 735 | 735 | |
| 736 | 736 | /** | 
| @@ -746,7 +746,7 @@ discard block | ||
| 746 | 746 | if (!in_array($element, $this->multiplePropertiesForElementAllowed) | 
| 747 | 747 | && isset($this->definedElements[$element]) | 
| 748 | 748 |          ) { | 
| 749 | -            throw new Exception('You can only set "' . $element . '" once.'); | |
| 749 | +            throw new Exception('You can only set "'.$element.'" once.'); | |
| 750 | 750 | } | 
| 751 | 751 | |
| 752 | 752 | // we define that we set this element |