aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/DAV/StringUtil.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-11-10 12:49:51 +0000
committerMario <mario@mariovavti.com>2019-11-10 14:10:03 +0100
commit580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch)
tree82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/dav/lib/DAV/StringUtil.php
parentd22766f458a8539a40a57f3946459a9be1f21cd6 (diff)
downloadvolse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.gz
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.bz2
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.zip
another bulk of composer updates
(cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce)
Diffstat (limited to 'vendor/sabre/dav/lib/DAV/StringUtil.php')
-rw-r--r--vendor/sabre/dav/lib/DAV/StringUtil.php57
1 files changed, 27 insertions, 30 deletions
diff --git a/vendor/sabre/dav/lib/DAV/StringUtil.php b/vendor/sabre/dav/lib/DAV/StringUtil.php
index 10eecebfd..13a4399e3 100644
--- a/vendor/sabre/dav/lib/DAV/StringUtil.php
+++ b/vendor/sabre/dav/lib/DAV/StringUtil.php
@@ -1,9 +1,11 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV;
/**
- * String utility
+ * String utility.
*
* This class is mainly used to implement the 'text-match' filter, used by both
* the CalDAV calendar-query REPORT, and CardDAV addressbook-query REPORT.
@@ -13,79 +15,74 @@ namespace Sabre\DAV;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class StringUtil {
-
+class StringUtil
+{
/**
- * Checks if a needle occurs in a haystack ;)
+ * Checks if a needle occurs in a haystack ;).
*
* @param string $haystack
* @param string $needle
* @param string $collation
* @param string $matchType
+ *
* @return bool
*/
- static function textMatch($haystack, $needle, $collation, $matchType = 'contains') {
-
+ public static function textMatch($haystack, $needle, $collation, $matchType = 'contains')
+ {
switch ($collation) {
-
- case 'i;ascii-casemap' :
+ case 'i;ascii-casemap':
// default strtolower takes locale into consideration
// we don't want this.
$haystack = str_replace(range('a', 'z'), range('A', 'Z'), $haystack);
$needle = str_replace(range('a', 'z'), range('A', 'Z'), $needle);
break;
- case 'i;octet' :
+ case 'i;octet':
// Do nothing
break;
- case 'i;unicode-casemap' :
+ case 'i;unicode-casemap':
$haystack = mb_strtoupper($haystack, 'UTF-8');
$needle = mb_strtoupper($needle, 'UTF-8');
break;
- default :
- throw new Exception\BadRequest('Collation type: ' . $collation . ' is not supported');
-
+ default:
+ throw new Exception\BadRequest('Collation type: '.$collation.' is not supported');
}
switch ($matchType) {
-
- case 'contains' :
- return strpos($haystack, $needle) !== false;
- case 'equals' :
+ case 'contains':
+ return false !== strpos($haystack, $needle);
+ case 'equals':
return $haystack === $needle;
- case 'starts-with' :
- return strpos($haystack, $needle) === 0;
- case 'ends-with' :
+ case 'starts-with':
+ return 0 === strpos($haystack, $needle);
+ case 'ends-with':
return strrpos($haystack, $needle) === strlen($haystack) - strlen($needle);
- default :
- throw new Exception\BadRequest('Match-type: ' . $matchType . ' is not supported');
-
+ default:
+ throw new Exception\BadRequest('Match-type: '.$matchType.' is not supported');
}
-
}
/**
* This method takes an input string, checks if it's not valid UTF-8 and
* attempts to convert it to UTF-8 if it's not.
*
- * Note that currently this can only convert ISO-8559-1 to UTF-8 (latin-1),
+ * Note that currently this can only convert ISO-8859-1 to UTF-8 (latin-1),
* anything else will likely fail.
*
* @param string $input
+ *
* @return string
*/
- static function ensureUTF8($input) {
-
+ public static function ensureUTF8($input)
+ {
$encoding = mb_detect_encoding($input, ['UTF-8', 'ISO-8859-1'], true);
- if ($encoding === 'ISO-8859-1') {
+ if ('ISO-8859-1' === $encoding) {
return utf8_encode($input);
} else {
return $input;
}
-
}
-
}