aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib/PagedResults/TLinkId.php
blob: 46d392995e015fd79f5da6c2fbeb2b4c7d40d7ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCA\User_LDAP\PagedResults;

trait TLinkId {
	public function getLinkId($link) {
		if (is_object($link)) {
			return spl_object_id($link);
		} elseif (is_resource($link)) {
			return (int)$link;
		} elseif (is_array($link) && isset($link[0])) {
			if (is_object($link[0])) {
				return spl_object_id($link[0]);
			} elseif (is_resource($link[0])) {
				return (int)$link[0];
			}
		}
		throw new \RuntimeException('No resource provided');
	}
}