Skip to content

Commit

Permalink
Re-order methods
Browse files Browse the repository at this point in the history
  • Loading branch information
u01jmg3 committed Aug 1, 2017
1 parent 4000d5e commit 50a8497
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ var_dump($event->dtstart_array);
| `isFileOrUrl` | `$filename` | `protected` | Checks if a filename exists as a file or URL |
| `isValidTimeZoneId` | `$timeZone` | `protected` | Checks if a time zone is valid |
| `keyValueFromString` | `$text` | `protected` | Gets the key value pair from an iCal string |
| `mb_chr` | `$code` | `protected` | Provides a polyfill for PHP 7.2's `mb_chr()`, which is a multibyte safe version of `chr()` |
| `mb_str_replace` | `$search`, `$replace`, `$subject`, `$count = 0` | `protected` | Replaces all occurrences of a search string with a given replacement string |
| `mb_chr` | `$code` | `protected` | Provides a polyfill for PHP 7.2's mb_chr(), which is a multibyte safe version of chr(). |
| `numberOfDays` | `$days`, `$start`, `$end` | `protected` | Gets the number of days between a start and end date |
| `parseDuration` | `$date`, `$duration`, `$format = 'U'` | `protected` | Parses a duration and applies it to a date |
| `processDateConversions` | - | `protected` | Processes date conversions using the time zone |
Expand Down
52 changes: 26 additions & 26 deletions src/ICal/ICal.php
Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,32 @@ protected function removeUnprintableChars($data)
return preg_replace('/[\x00-\x1F\x7F\xA0]/u', '', $data);
}

/**
* Provides a polyfill for PHP 7.2's `mb_chr()`, which is a multibyte safe version of `chr()`.
* Multibyte safe.
*
* @param integer $code
* @return string
*/
protected function mb_chr($code)
{
if (function_exists('mb_chr')) {
return mb_chr($code);
} else {
if (0x80 > $code %= 0x200000) {
$s = chr($code);
} elseif (0x800 > $code) {
$s = chr(0xc0 | $code >> 6) . chr(0x80 | $code & 0x3f);
} elseif (0x10000 > $code) {
$s = chr(0xe0 | $code >> 12) . chr(0x80 | $code >> 6 & 0x3f) . chr(0x80 | $code & 0x3f);
} else {
$s = chr(0xf0 | $code >> 18) . chr(0x80 | $code >> 12 & 0x3f) . chr(0x80 | $code >> 6 & 0x3f) . chr(0x80 | $code & 0x3f);
}

return $s;
}
}

/**
* Replaces all occurrences of a search string with a given replacement string.
* Multibyte safe.
Expand Down Expand Up @@ -1921,32 +1947,6 @@ protected function mb_str_replace($search, $replace, $subject, &$count = 0)
return $subject;
}

/**
* Provides a polyfill for PHP 7.2's mb_chr(), which is a multibyte safe version of chr().
* Multibyte safe.
*
* @param integer $code
* @return string
*/
protected function mb_chr($code)
{
if (function_exists('mb_chr')) {
return mb_chr($code);
} else {
if (0x80 > $code %= 0x200000) {
$s = chr($code);
} elseif (0x800 > $code) {
$s = chr(0xC0 | $code >> 6) . chr(0x80 | $code & 0x3F);
} elseif (0x10000 > $code) {
$s = chr(0xE0 | $code >> 12) . chr(0x80 | $code >> 6 & 0x3F) . chr(0x80 | $code & 0x3F);
} else {
$s = chr(0xF0 | $code >> 18) . chr(0x80 | $code >> 12 & 0x3F) . chr(0x80 | $code >> 6 & 0x3F) . chr(0x80 | $code & 0x3F);
}

return $s;
}
}

/**
* Replaces curly quotes and other special characters
* with their standard equivalents
Expand Down

0 comments on commit 50a8497

Please sign in to comment.