Skip to content

Commit 8b4dda6

Browse files
committed
Wrap lines at 72
1 parent 7b30773 commit 8b4dda6

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

examples/simpleevent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@
5151
// write iCalendar feed to stdout
5252
echo $icalobj->export();
5353

54-
file_put_contents('simpleEvent.ics', $icalobj->export());
54+
\file_put_contents('simpleEvent.ics', $icalobj->export());

src/ICalendarOrg/ZCRecurringDate.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ public function debug(int $level, string $msg) : self
423423
*/
424424
public function getDates(?int $maxdate = null) : array
425425
{
426-
//$this->debug = 2;
427426
self::debug(1, 'getDates()');
428427
$nextdate = $enddate = $this->startdate;
429428
$rdates = [];
@@ -703,7 +702,6 @@ private function byDay(int $startdate, int $enddate, array &$rdates, string $tzi
703702
{
704703
$rdates[] = $wdate;
705704
$count++;
706-
//break;
707705
}
708706
}
709707
}

src/ICalendarOrg/ZCiCalDataNode.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public function __construct(string $line)
7575
{
7676
$value = \str_replace('`~', '\\:', \substr($line, $i + 1));
7777
// fix escaped characters (don't see double quotes in spec but Apple apparently uses it in iCal)
78-
// $value = \str_replace(['\\N', '\\n', '\\"'], ["\n", "\n", '"'], $value);
7978
$tvalue = \str_replace('\\,', '`~', $value);
8079
$tvalue = \explode(',', $tvalue);
8180
$value = \str_replace('`~', '\\,', $tvalue);
@@ -126,21 +125,24 @@ public function __toString() : string
126125
$output .= ':' . $this->getValues();
127126
}
128127

129-
$final = $output;
128+
$final = '';
130129

131-
if (\strlen($final) > 70)
130+
$parts = \explode("\n", $output);
131+
132+
foreach ($parts as $index => $value)
132133
{
133-
$final = '';
134+
$part = '';
134135

135-
while (\strlen($output) > 70)
136+
while (\strlen($value) > 70)
136137
{
137-
$final = $final . \substr($output, 0, 67) . " \r\n";
138-
$output = \substr($output, 67);
138+
$part = $part . \substr($value, 0, 67) . " \r\n";
139+
$value = \substr($value, 67);
139140
}
140-
$final .= $output;
141+
$part .= $value;
142+
$parts[$index] = $part;
141143
}
142144

143-
return $final . "\r\n";
145+
return \implode("\n", $parts) . "\r\n";
144146
}
145147

146148
/**

src/ICalendarOrg/ZCiCalNode.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ public function export(?ZCiCalNode $node = null, int $level = 0) : string
143143

144144
if ($level > 5)
145145
{
146-
//die("levels nested too deep<br/>\n");
147146
throw new \Exception('levels nested too deep');
148147
}
149148
$txtstr .= 'BEGIN:' . $node->getName() . "\r\n";
@@ -257,7 +256,6 @@ public function printTree(?ZCiCalNode $node = null, int $level = 1) : string
257256
if ($level > 5)
258257
{
259258
exit("levels nested too deep<br/>\n");
260-
//return;
261259
}
262260

263261
for ($i = 0; $i < $level; $i++)

tests/ZCiCalDataNodeTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function testZCiCalDataNode(string $line) : void
1818
{
1919
$dataNode = new \ICalendarOrg\ZCiCalDataNode($line);
2020
$generated = "{$dataNode}";
21-
$this->assertEquals($line . "\n", $generated, $line . ' has an error');
21+
$this->assertEquals($line . "\r\n", $generated, $line . ' has an error');
2222
}
2323

2424
/**
@@ -30,11 +30,11 @@ public function providerZCiCalDataNode() : array
3030
{
3131
return [
3232
['ACTION:AUDIO'],
33-
['ATTACH;FMTTYPE=application/postscript:ftp://example.com/pub/conf/bkgrnd.ps'],
34-
['ATTACH;FMTTYPE=audio/basic:http://example.com/pub/audio-files/ssbanner.aud'],
33+
['ATTACH;FMTTYPE=application/postscript:ftp://example.com/pub/bkgrnd.ps'],
34+
['ATTACH;FMTTYPE=audio/basic:http://example.com/pub/ssbanner.aud'],
3535
['ATTENDEE;PARTSTAT=ACCEPTED:mailto:[email protected]'],
3636
['ATTENDEE;RSVP=TRUE:mailto:[email protected]'],
37-
['ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:mailto:employee-A@example.com'],
37+
['ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:mailto:a@ex.com'],
3838
['CATEGORIES:CONFERENCE'],
3939
['CATEGORIES:MEETING'],
4040
['CATEGORIES:MEETING,PROJECT'],
@@ -53,9 +53,11 @@ public function providerZCiCalDataNode() : array
5353
2. Definitionof project processes.
5454
3. Review of project schedule.
5555
Participants: John Smith, Jane Doe, Jim Dandy
56-
-It was decided that the requirements need to be signed off by product marketing.
56+
-It was decided that the requirements need to be signed off by
57+
product marketing.
5758
-Project processes were accepted.
58-
-Project schedule needs to account for scheduled holidays and employee vacation time. Check with HR for specific dates.
59+
-Project schedule needs to account for scheduled holidays and
60+
employee vacation time. Check with HR for specific dates.
5961
-New schedule will be distributed by Friday.
6062
-Next weeks meeting is cancelled. No meeting until 3/23.'],
6163
['DTEND:19960920T220000Z'],

0 commit comments

Comments
 (0)