SystemTag.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Johannes Leuker <j.leuker@hosting.de>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. * @author Vincent Petry <vincent@nextcloud.com>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OC\SystemTag;
  27. use OCP\SystemTag\ISystemTag;
  28. class SystemTag implements ISystemTag {
  29. /**
  30. * @var string
  31. */
  32. private $id;
  33. /**
  34. * @var string
  35. */
  36. private $name;
  37. /**
  38. * @var bool
  39. */
  40. private $userVisible;
  41. /**
  42. * @var bool
  43. */
  44. private $userAssignable;
  45. /**
  46. * Constructor.
  47. *
  48. * @param string $id tag id
  49. * @param string $name tag name
  50. * @param bool $userVisible whether the tag is user visible
  51. * @param bool $userAssignable whether the tag is user assignable
  52. */
  53. public function __construct(string $id, string $name, bool $userVisible, bool $userAssignable) {
  54. $this->id = $id;
  55. $this->name = $name;
  56. $this->userVisible = $userVisible;
  57. $this->userAssignable = $userAssignable;
  58. }
  59. /**
  60. * {@inheritdoc}
  61. */
  62. public function getId(): string {
  63. return $this->id;
  64. }
  65. /**
  66. * {@inheritdoc}
  67. */
  68. public function getName(): string {
  69. return $this->name;
  70. }
  71. /**
  72. * {@inheritdoc}
  73. */
  74. public function isUserVisible(): bool {
  75. return $this->userVisible;
  76. }
  77. /**
  78. * {@inheritdoc}
  79. */
  80. public function isUserAssignable(): bool {
  81. return $this->userAssignable;
  82. }
  83. /**
  84. * {@inheritdoc}
  85. */
  86. public function getAccessLevel(): int {
  87. if ($this->userVisible) {
  88. if ($this->userAssignable) {
  89. return self::ACCESS_LEVEL_PUBLIC;
  90. } else {
  91. return self::ACCESS_LEVEL_RESTRICTED;
  92. }
  93. } else {
  94. return self::ACCESS_LEVEL_INVISIBLE;
  95. }
  96. }
  97. }