scimserviceprovider/lib/Util/Util.php

34 lines
787 B
PHP
Raw Permalink Normal View History

2023-03-03 11:21:27 +00:00
<?php
namespace OCA\SCIMServiceProvider\Util;
2024-02-06 10:32:35 +00:00
use OCP\IRequest;
2023-03-03 11:21:27 +00:00
2024-02-06 10:32:35 +00:00
class Util {
public const SCIM_APP_URL_PATH = "index.php/apps/scimserviceprovider";
2023-03-03 11:21:27 +00:00
2024-02-06 10:32:35 +00:00
public static function getBaseUrl(IRequest $request) : string {
return $request->getServerProtocol() . "://" . $request->getServerHost() . "/" . Util::SCIM_APP_URL_PATH;
}
public static function parsePagination(array $params): array {
if (isset($params["startIndex"])) {
$startIndex = intval($params["startIndex"]);
if ($startIndex < 1) {
$startIndex = 1;
}
$params["startIndex"] = $startIndex;
} else {
$params["startIndex"] = 1;
}
if (isset($params["count"])) {
$count = intval($params["count"]);
if ($count < 0) {
$count = 0;
}
$params["count"] = $count;
}
return $params;
}
2023-03-03 11:21:27 +00:00
}