EnforcementState.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Authentication\TwoFactorAuth;
  8. use JsonSerializable;
  9. class EnforcementState implements JsonSerializable {
  10. /** @var bool */
  11. private $enforced;
  12. /** @var array */
  13. private $enforcedGroups;
  14. /** @var array */
  15. private $excludedGroups;
  16. /**
  17. * EnforcementState constructor.
  18. *
  19. * @param bool $enforced
  20. * @param string[] $enforcedGroups
  21. * @param string[] $excludedGroups
  22. */
  23. public function __construct(bool $enforced,
  24. array $enforcedGroups = [],
  25. array $excludedGroups = []) {
  26. $this->enforced = $enforced;
  27. $this->enforcedGroups = $enforcedGroups;
  28. $this->excludedGroups = $excludedGroups;
  29. }
  30. /**
  31. * @return bool
  32. */
  33. public function isEnforced(): bool {
  34. return $this->enforced;
  35. }
  36. /**
  37. * @return string[]
  38. */
  39. public function getEnforcedGroups(): array {
  40. return $this->enforcedGroups;
  41. }
  42. /**
  43. * @return string[]
  44. */
  45. public function getExcludedGroups(): array {
  46. return $this->excludedGroups;
  47. }
  48. public function jsonSerialize(): array {
  49. return [
  50. 'enforced' => $this->enforced,
  51. 'enforcedGroups' => $this->enforcedGroups,
  52. 'excludedGroups' => $this->excludedGroups,
  53. ];
  54. }
  55. }