IAttributes.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2019 ownCloud GmbH
  4. * SPDX-License-Identifier: AGPL-3.0-only
  5. */
  6. namespace OCP\Share;
  7. /**
  8. * Interface IAttributes
  9. *
  10. * @package OCP\Share
  11. * @since 25.0.0
  12. */
  13. interface IAttributes {
  14. /**
  15. * Sets an attribute. If the key did not exist before it will be created.
  16. *
  17. * @param string $scope scope
  18. * @param string $key key
  19. * @param bool|string|array|null $value value
  20. * @return IAttributes The modified object
  21. * @since 25.0.0
  22. */
  23. public function setAttribute(string $scope, string $key, mixed $value): IAttributes;
  24. /**
  25. * Returns the attribute for given scope id and key.
  26. * If attribute does not exist, returns null
  27. *
  28. * @param string $scope scope
  29. * @param string $key key
  30. * @return bool|string|array|null
  31. * @since 25.0.0
  32. */
  33. public function getAttribute(string $scope, string $key): mixed;
  34. /**
  35. * Formats the IAttributes object to array with the following format:
  36. * [
  37. * 0 => [
  38. * "scope" => <string>,
  39. * "key" => <string>,
  40. * "value" => <bool|string|array|null>,
  41. * ],
  42. * ...
  43. * ]
  44. *
  45. * @return array formatted IAttributes
  46. * @since 25.0.0
  47. * @since 30.0.0, `enabled` was renamed to `value`
  48. */
  49. public function toArray(): array;
  50. }