TLinkId.php 615 B

1234567891011121314151617181920212223242526
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\User_LDAP\PagedResults;
  8. trait TLinkId {
  9. public function getLinkId($link) {
  10. if (is_object($link)) {
  11. return spl_object_id($link);
  12. } elseif (is_resource($link)) {
  13. return (int)$link;
  14. } elseif (is_array($link) && isset($link[0])) {
  15. if (is_object($link[0])) {
  16. return spl_object_id($link[0]);
  17. } elseif (is_resource($link[0])) {
  18. return (int)$link[0];
  19. }
  20. }
  21. throw new \RuntimeException('No resource provided');
  22. }
  23. }