| @@ -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 | |
| @@ -182,7 +182,7 @@ discard block | ||
| 182 | 182 |      { | 
| 183 | 183 | $this->setProperty( | 
| 184 | 184 | 'role', | 
| 185 | - 'ROLE' . $this->getCharsetString(), | |
| 185 | + 'ROLE'.$this->getCharsetString(), | |
| 186 | 186 | $role | 
| 187 | 187 | ); | 
| 188 | 188 | |
| @@ -216,7 +216,7 @@ discard block | ||
| 216 | 216 | |
| 217 | 217 |              $type = strtoupper(str_replace('image/', '', $mimetype)); | 
| 218 | 218 | |
| 219 | - $property .= ";ENCODING=b;TYPE=" . $type; | |
| 219 | + $property .= ";ENCODING=b;TYPE=".$type; | |
| 220 | 220 |          } else { | 
| 221 | 221 |              if (filter_var($url, FILTER_VALIDATE_URL) !== FALSE) { | 
| 222 | 222 | $propertySuffix = ';VALUE=URL'; | 
| @@ -237,9 +237,9 @@ discard block | ||
| 237 | 237 |                      throw new VCardMediaException('Returned data isn\'t an image.'); | 
| 238 | 238 | } | 
| 239 | 239 | |
| 240 | - $propertySuffix .= ';TYPE=' . strtoupper($fileType); | |
| 240 | + $propertySuffix .= ';TYPE='.strtoupper($fileType); | |
| 241 | 241 | |
| 242 | - $property = $property . $propertySuffix; | |
| 242 | + $property = $property.$propertySuffix; | |
| 243 | 243 | $value = $url; | 
| 244 | 244 |              } else { | 
| 245 | 245 | $value = $url; | 
| @@ -283,10 +283,10 @@ discard block | ||
| 283 | 283 | $this->setFilename($values); | 
| 284 | 284 | |
| 285 | 285 | // set property | 
| 286 | - $property = $lastName . ';' . $firstName . ';' . $additional . ';' . $prefix . ';' . $suffix; | |
| 286 | + $property = $lastName.';'.$firstName.';'.$additional.';'.$prefix.';'.$suffix; | |
| 287 | 287 | $this->setProperty( | 
| 288 | 288 | 'name', | 
| 289 | - 'N' . $this->getCharsetString(), | |
| 289 | + 'N'.$this->getCharsetString(), | |
| 290 | 290 | $property | 
| 291 | 291 | ); | 
| 292 | 292 | |
| @@ -295,7 +295,7 @@ discard block | ||
| 295 | 295 | // set property | 
| 296 | 296 | $this->setProperty( | 
| 297 | 297 | 'fullname', | 
| 298 | - 'FN' . $this->getCharsetString(), | |
| 298 | + 'FN'.$this->getCharsetString(), | |
| 299 | 299 |                  trim(implode(' ', $values)) | 
| 300 | 300 | ); | 
| 301 | 301 | } | 
| @@ -313,7 +313,7 @@ discard block | ||
| 313 | 313 |      { | 
| 314 | 314 | $this->setProperty( | 
| 315 | 315 | 'note', | 
| 316 | - 'NOTE' . $this->getCharsetString(), | |
| 316 | + 'NOTE'.$this->getCharsetString(), | |
| 317 | 317 | $note | 
| 318 | 318 | ); | 
| 319 | 319 | |
| @@ -334,7 +334,7 @@ discard block | ||
| 334 | 334 |      { | 
| 335 | 335 | $this->setProperty( | 
| 336 | 336 | 'phoneNumber', | 
| 337 | - 'TEL' . (($type != '') ? ';' . $type : ''), | |
| 337 | + 'TEL'.(($type != '') ? ';'.$type : ''), | |
| 338 | 338 | $number | 
| 339 | 339 | ); | 
| 340 | 340 | |
| @@ -390,7 +390,7 @@ discard block | ||
| 390 | 390 |      { | 
| 391 | 391 | $this->setProperty( | 
| 392 | 392 | 'url', | 
| 393 | - 'URL' . (($type != '') ? ';' . $type : ''), | |
| 393 | + 'URL'.(($type != '') ? ';'.$type : ''), | |
| 394 | 394 | $url | 
| 395 | 395 | ); | 
| 396 | 396 | |
| @@ -407,13 +407,13 @@ discard block | ||
| 407 | 407 | // init string | 
| 408 | 408 | $string = "BEGIN:VCARD\r\n"; | 
| 409 | 409 | $string .= "VERSION:3.0\r\n"; | 
| 410 | -        $string .= "REV:" . date("Y-m-d") . "T" . date("H:i:s") . "Z\r\n"; | |
| 410 | +        $string .= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n"; | |
| 411 | 411 | |
| 412 | 412 | // loop all properties | 
| 413 | 413 | $properties = $this->getProperties(); | 
| 414 | 414 |          foreach ($properties as $property) { | 
| 415 | 415 | // add to string | 
| 416 | - $string .= $this->fold($property['key'] . ':' . $this->escape($property['value']) . "\r\n"); | |
| 416 | + $string .= $this->fold($property['key'].':'.$this->escape($property['value'])."\r\n"); | |
| 417 | 417 | } | 
| 418 | 418 | |
| 419 | 419 | // add to string | 
| @@ -431,19 +431,19 @@ discard block | ||
| 431 | 431 | public function buildVCalendar() | 
| 432 | 432 |      { | 
| 433 | 433 | // init dates | 
| 434 | -        $dtstart = date("Ymd") . "T" . date("Hi") . "00"; | |
| 435 | -        $dtend = date("Ymd") . "T" . date("Hi") . "01"; | |
| 434 | +        $dtstart = date("Ymd")."T".date("Hi")."00"; | |
| 435 | +        $dtend = date("Ymd")."T".date("Hi")."01"; | |
| 436 | 436 | |
| 437 | 437 | // init string | 
| 438 | 438 | $string = "BEGIN:VCALENDAR\n"; | 
| 439 | 439 | $string .= "VERSION:2.0\n"; | 
| 440 | 440 | $string .= "BEGIN:VEVENT\n"; | 
| 441 | - $string .= "DTSTART;TZID=Europe/London:" . $dtstart . "\n"; | |
| 442 | - $string .= "DTEND;TZID=Europe/London:" . $dtend . "\n"; | |
| 441 | + $string .= "DTSTART;TZID=Europe/London:".$dtstart."\n"; | |
| 442 | + $string .= "DTEND;TZID=Europe/London:".$dtend."\n"; | |
| 443 | 443 | $string .= "SUMMARY:Click attached contact below to save to your contacts\n"; | 
| 444 | - $string .= "DTSTAMP:" . $dtstart . "Z\n"; | |
| 444 | + $string .= "DTSTAMP:".$dtstart."Z\n"; | |
| 445 | 445 | $string .= "ATTACH;VALUE=BINARY;ENCODING=BASE64;FMTTYPE=text/directory;\n"; | 
| 446 | - $string .= " X-APPLE-FILENAME=" . $this->getFilename() . "." . $this->getFileExtension() . ":\n"; | |
| 446 | + $string .= " X-APPLE-FILENAME=".$this->getFilename().".".$this->getFileExtension().":\n"; | |
| 447 | 447 | |
| 448 | 448 | // base64 encode it so that it can be used as an attachemnt to the "dummy" calendar appointment | 
| 449 | 449 | $b64vcard = base64_encode($this->buildVCard()); | 
| @@ -570,7 +570,7 @@ discard block | ||
| 570 | 570 |      { | 
| 571 | 571 | $charsetString = ''; | 
| 572 | 572 |          if ($this->charset == 'utf-8') { | 
| 573 | - $charsetString = ';CHARSET=' . $this->charset; | |
| 573 | + $charsetString = ';CHARSET='.$this->charset; | |
| 574 | 574 | } | 
| 575 | 575 | return $charsetString; | 
| 576 | 576 | } | 
| @@ -615,8 +615,8 @@ discard block | ||
| 615 | 615 | */ | 
| 616 | 616 | public function getHeaders($asAssociative) | 
| 617 | 617 |      { | 
| 618 | - $contentType = $this->getContentType() . '; charset=' . $this->getCharset(); | |
| 619 | - $contentDisposition = 'attachment; filename=' . $this->getFilename() . '.' . $this->getFileExtension(); | |
| 618 | + $contentType = $this->getContentType().'; charset='.$this->getCharset(); | |
| 619 | + $contentDisposition = 'attachment; filename='.$this->getFilename().'.'.$this->getFileExtension(); | |
| 620 | 620 | $contentLength = strlen($this->getOutput()); | 
| 621 | 621 | $connection = 'close'; | 
| 622 | 622 | |
| @@ -630,10 +630,10 @@ discard block | ||
| 630 | 630 | } | 
| 631 | 631 | |
| 632 | 632 | return array( | 
| 633 | - 'Content-type: ' . $contentType, | |
| 634 | - 'Content-Disposition: ' . $contentDisposition, | |
| 635 | - 'Content-Length: ' . $contentLength, | |
| 636 | - 'Connection: ' . $connection, | |
| 633 | + 'Content-type: '.$contentType, | |
| 634 | + 'Content-Disposition: '.$contentDisposition, | |
| 635 | + 'Content-Length: '.$contentLength, | |
| 636 | + 'Connection: '.$connection, | |
| 637 | 637 | ); | 
| 638 | 638 | } | 
| 639 | 639 | |
| @@ -711,7 +711,7 @@ discard block | ||
| 711 | 711 | */ | 
| 712 | 712 | public function save() | 
| 713 | 713 |      { | 
| 714 | - $file = $this->getFilename() . '.' . $this->getFileExtension(); | |
| 714 | + $file = $this->getFilename().'.'.$this->getFileExtension(); | |
| 715 | 715 | |
| 716 | 716 | file_put_contents( | 
| 717 | 717 | $file, | 
| @@ -764,7 +764,7 @@ discard block | ||
| 764 | 764 | |
| 765 | 765 | // overwrite filename or add to filename using a prefix in between | 
| 766 | 766 | $this->filename = ($overwrite) ? | 
| 767 | - $value : $this->filename . $separator . $value; | |
| 767 | + $value : $this->filename.$separator.$value; | |
| 768 | 768 | } | 
| 769 | 769 | |
| 770 | 770 | /** | 
| @@ -780,7 +780,7 @@ discard block | ||
| 780 | 780 | if (!in_array($element, $this->multiplePropertiesForElementAllowed) | 
| 781 | 781 | && isset($this->definedElements[$element]) | 
| 782 | 782 |          ) { | 
| 783 | -            throw new Exception('You can only set "' . $element . '" once.'); | |
| 783 | +            throw new Exception('You can only set "'.$element.'" once.'); | |
| 784 | 784 | } | 
| 785 | 785 | |
| 786 | 786 | // we define that we set this element |