Completed
Pull Request — master (#96)
by Marcus
01:23
created
src/VCardParser.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 {
39 39
     /**
40 40
      * The raw VCard content.
41
-    *
41
+     *
42 42
      * @var string
43 43
      */
44 44
     protected $content;
Please login to merge, or discard this patch.
examples/example.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
  * VCard generator test - can save to file or output as a download
5 5
  */
6 6
 
7
-require_once __DIR__ . '/../vendor/autoload.php';
8
-require_once __DIR__ . '/../src/VCard.php';
7
+require_once __DIR__.'/../vendor/autoload.php';
8
+require_once __DIR__.'/../src/VCard.php';
9 9
 
10 10
 use JeroenDesloovere\VCard\VCard;
11 11
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 $vcard->addAddress(null, null, 'street', 'worktown', null, 'workpostcode', 'Belgium');
32 32
 $vcard->addURL('http://www.jeroendesloovere.be');
33 33
 
34
-$vcard->addPhoto(__DIR__ . '/assets/landscape.jpeg');
34
+$vcard->addPhoto(__DIR__.'/assets/landscape.jpeg');
35 35
 //$vcard->addPhoto('https://raw.githubusercontent.com/jeroendesloovere/vcard/master/tests/image.jpg');
36 36
 
37 37
 // return vcard as a string
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 return $vcard->download();
42 42
 
43 43
 // echo message
44
-echo 'A personal vCard is saved in this folder: ' . __DIR__;
44
+echo 'A personal vCard is saved in this folder: '.__DIR__;
45 45
 
46 46
 // or
47 47
 
Please login to merge, or discard this patch.
examples/example_parsing.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@
 block discarded – undo
4 4
  * VCardParser test - can parse bundled VCF file into CSV
5 5
  */
6 6
 
7
-require_once __DIR__ . '/../vendor/autoload.php';
8
-require_once __DIR__ . '/../src/VCardParser.php';
7
+require_once __DIR__.'/../vendor/autoload.php';
8
+require_once __DIR__.'/../src/VCardParser.php';
9 9
 
10 10
 // load VCardParser classes
11 11
 use JeroenDesloovere\VCard\VCardParser;
12 12
 
13
-$pathToVCardExample = __DIR__ . '/assets/contacts.vcf';
13
+$pathToVCardExample = __DIR__.'/assets/contacts.vcf';
14 14
 $parser = VCardParser::parseFromFile($pathToVCardExample);
15 15
 
16
-foreach($parser as $vcard) {
16
+foreach ($parser as $vcard) {
17 17
     $lastname = $vcard->lastname;
18 18
     $firstname = $vcard->firstname;
19 19
     $birthday = $vcard->birthday->format('Y-m-d');
Please login to merge, or discard this patch.
src/VCard.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
         $type = 'WORK;POSTAL'
92 92
     ) {
93 93
         // init value
94
-        $value = $name . ';' . $extended . ';' . $street . ';' . $city . ';' . $region . ';' . $zip . ';' . $country;
94
+        $value = $name.';'.$extended.';'.$street.';'.$city.';'.$region.';'.$zip.';'.$country;
95 95
 
96 96
         // set property
97 97
         $this->setProperty(
98 98
             'address',
99
-            'ADR' . (($type != '') ? ';' . $type : '') . $this->getCharsetString(),
99
+            'ADR'.(($type != '') ? ';'.$type : '').$this->getCharsetString(),
100 100
             $value
101 101
         );
102 102
 
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
     {
132 132
         $this->setProperty(
133 133
             'company',
134
-            'ORG' . $this->getCharsetString(),
134
+            'ORG'.$this->getCharsetString(),
135 135
             $company
136
-            . ($department != '' ? ';' . $department : '')
136
+            . ($department != '' ? ';'.$department : '')
137 137
         );
138 138
 
139 139
         // if filename is empty, add to filename
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     {
158 158
         $this->setProperty(
159 159
             'email',
160
-            'EMAIL;INTERNET' . (($type != '') ? ';' . $type : ''),
160
+            'EMAIL;INTERNET'.(($type != '') ? ';'.$type : ''),
161 161
             $address
162 162
         );
163 163
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     {
175 175
         $this->setProperty(
176 176
             'jobtitle',
177
-            'TITLE' . $this->getCharsetString(),
177
+            'TITLE'.$this->getCharsetString(),
178 178
             $jobtitle
179 179
         );
180 180
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     {
192 192
         $this->setProperty(
193 193
             'role',
194
-            'ROLE' . $this->getCharsetString(),
194
+            'ROLE'.$this->getCharsetString(),
195 195
             $role
196 196
         );
197 197
 
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
             }
242 242
 
243 243
             $value = base64_encode($value);
244
-            $property .= ";ENCODING=b;TYPE=" . $fileType;
244
+            $property .= ";ENCODING=b;TYPE=".$fileType;
245 245
         } else {
246 246
             if (filter_var($url, FILTER_VALIDATE_URL) !== false) {
247 247
                 $propertySuffix = ';VALUE=URL';
248
-                $propertySuffix .= ';TYPE=' . strtoupper($fileType);
248
+                $propertySuffix .= ';TYPE='.strtoupper($fileType);
249 249
 
250
-                $property = $property . $propertySuffix;
250
+                $property = $property.$propertySuffix;
251 251
                 $value = $url;
252 252
             } else {
253 253
                 $value = $url;
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
         $this->setFilename($values);
292 292
 
293 293
         // set property
294
-        $property = $lastName . ';' . $firstName . ';' . $additional . ';' . $prefix . ';' . $suffix;
294
+        $property = $lastName.';'.$firstName.';'.$additional.';'.$prefix.';'.$suffix;
295 295
         $this->setProperty(
296 296
             'name',
297
-            'N' . $this->getCharsetString(),
297
+            'N'.$this->getCharsetString(),
298 298
             $property
299 299
         );
300 300
 
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
             // set property
304 304
             $this->setProperty(
305 305
                 'fullname',
306
-                'FN' . $this->getCharsetString(),
306
+                'FN'.$this->getCharsetString(),
307 307
                 trim(implode(' ', $values))
308 308
             );
309 309
         }
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     {
322 322
         $this->setProperty(
323 323
             'note',
324
-            'NOTE' . $this->getCharsetString(),
324
+            'NOTE'.$this->getCharsetString(),
325 325
             $note
326 326
         );
327 327
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
     {
339 339
         $this->setProperty(
340 340
             'categories',
341
-            'CATEGORIES' . $this->getCharsetString(),
341
+            'CATEGORIES'.$this->getCharsetString(),
342 342
             trim(implode(',', $categories))
343 343
         );
344 344
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
     {
360 360
         $this->setProperty(
361 361
             'phoneNumber',
362
-            'TEL' . (($type != '') ? ';' . $type : ''),
362
+            'TEL'.(($type != '') ? ';'.$type : ''),
363 363
             $number
364 364
         );
365 365
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
     {
416 416
         $this->setProperty(
417 417
             'url',
418
-            'URL' . (($type != '') ? ';' . $type : ''),
418
+            'URL'.(($type != '') ? ';'.$type : ''),
419 419
             $url
420 420
         );
421 421
 
@@ -432,13 +432,13 @@  discard block
 block discarded – undo
432 432
         // init string
433 433
         $string = "BEGIN:VCARD\r\n";
434 434
         $string .= "VERSION:3.0\r\n";
435
-        $string .= "REV:" . date("Y-m-d") . "T" . date("H:i:s") . "Z\r\n";
435
+        $string .= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n";
436 436
 
437 437
         // loop all properties
438 438
         $properties = $this->getProperties();
439 439
         foreach ($properties as $property) {
440 440
             // add to string
441
-            $string .= $this->fold($property['key'] . ':' . $this->escape($property['value']) . "\r\n");
441
+            $string .= $this->fold($property['key'].':'.$this->escape($property['value'])."\r\n");
442 442
         }
443 443
 
444 444
         // add to string
@@ -456,19 +456,19 @@  discard block
 block discarded – undo
456 456
     public function buildVCalendar()
457 457
     {
458 458
         // init dates
459
-        $dtstart = date("Ymd") . "T" . date("Hi") . "00";
460
-        $dtend = date("Ymd") . "T" . date("Hi") . "01";
459
+        $dtstart = date("Ymd")."T".date("Hi")."00";
460
+        $dtend = date("Ymd")."T".date("Hi")."01";
461 461
 
462 462
         // init string
463 463
         $string = "BEGIN:VCALENDAR\n";
464 464
         $string .= "VERSION:2.0\n";
465 465
         $string .= "BEGIN:VEVENT\n";
466
-        $string .= "DTSTART;TZID=Europe/London:" . $dtstart . "\n";
467
-        $string .= "DTEND;TZID=Europe/London:" . $dtend . "\n";
466
+        $string .= "DTSTART;TZID=Europe/London:".$dtstart."\n";
467
+        $string .= "DTEND;TZID=Europe/London:".$dtend."\n";
468 468
         $string .= "SUMMARY:Click attached contact below to save to your contacts\n";
469
-        $string .= "DTSTAMP:" . $dtstart . "Z\n";
469
+        $string .= "DTSTAMP:".$dtstart."Z\n";
470 470
         $string .= "ATTACH;VALUE=BINARY;ENCODING=BASE64;FMTTYPE=text/directory;\n";
471
-        $string .= " X-APPLE-FILENAME=" . $this->getFilename() . "." . $this->getFileExtension() . ":\n";
471
+        $string .= " X-APPLE-FILENAME=".$this->getFilename().".".$this->getFileExtension().":\n";
472 472
 
473 473
         // base64 encode it so that it can be used as an attachemnt to the "dummy" calendar appointment
474 474
         $b64vcard = base64_encode($this->buildVCard());
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
     {
596 596
         $charsetString = '';
597 597
         if ($this->charset == 'utf-8') {
598
-            $charsetString = ';CHARSET=' . $this->charset;
598
+            $charsetString = ';CHARSET='.$this->charset;
599 599
         }
600 600
 
601 601
         return $charsetString;
@@ -645,12 +645,12 @@  discard block
 block discarded – undo
645 645
      */
646 646
     public function getHeaders($asAssociative)
647 647
     {
648
-        $contentType = $this->getContentType() . '; charset=' . $this->getCharset();
649
-        $contentDisposition = 'attachment; filename=' . $this->getFilename() . '.' . $this->getFileExtension();
648
+        $contentType = $this->getContentType().'; charset='.$this->getCharset();
649
+        $contentDisposition = 'attachment; filename='.$this->getFilename().'.'.$this->getFileExtension();
650 650
         $contentLength = mb_strlen($this->getOutput(), $this->getCharset());
651 651
         $connection = 'close';
652 652
 
653
-        if ((bool)$asAssociative) {
653
+        if ((bool) $asAssociative) {
654 654
             return array(
655 655
                 'Content-type' => $contentType,
656 656
                 'Content-Disposition' => $contentDisposition,
@@ -660,10 +660,10 @@  discard block
 block discarded – undo
660 660
         }
661 661
 
662 662
         return array(
663
-            'Content-type: ' . $contentType,
664
-            'Content-Disposition: ' . $contentDisposition,
665
-            'Content-Length: ' . $contentLength,
666
-            'Connection: ' . $connection,
663
+            'Content-type: '.$contentType,
664
+            'Content-Disposition: '.$contentDisposition,
665
+            'Content-Length: '.$contentLength,
666
+            'Connection: '.$connection,
667 667
         );
668 668
     }
669 669
 
@@ -741,11 +741,11 @@  discard block
 block discarded – undo
741 741
      */
742 742
     public function save()
743 743
     {
744
-        $file = $this->getFilename() . '.' . $this->getFileExtension();
744
+        $file = $this->getFilename().'.'.$this->getFileExtension();
745 745
 
746 746
         // Add save path if given
747 747
         if (null !== $this->savePath) {
748
-            $file = $this->savePath . $file;
748
+            $file = $this->savePath.$file;
749 749
         }
750 750
 
751 751
         file_put_contents(
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 
800 800
         // overwrite filename or add to filename using a prefix in between
801 801
         $this->filename = ($overwrite) ?
802
-            $value : $this->filename . $separator . $value;
802
+            $value : $this->filename.$separator.$value;
803 803
     }
804 804
 
805 805
     /**
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
         if (!in_array($element, $this->multiplePropertiesForElementAllowed)
836 836
             && isset($this->definedElements[$element])
837 837
         ) {
838
-            throw new Exception('You can only set "' . $element . '" once.');
838
+            throw new Exception('You can only set "'.$element.'" once.');
839 839
         }
840 840
 
841 841
         // we define that we set this element
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
 
860 860
         $matches = array();
861 861
         preg_match('/os (\d+)_(\d+)\s+/', $browser, $matches);
862
-        $version = isset($matches[1]) ? ((int)$matches[1]) : 999;
862
+        $version = isset($matches[1]) ? ((int) $matches[1]) : 999;
863 863
 
864 864
         return ($version < 8);
865 865
     }
Please login to merge, or discard this patch.