1
0

AppScriptDependency.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OC;
  7. class AppScriptDependency {
  8. /** @var string */
  9. private $id;
  10. /** @var array */
  11. private $deps;
  12. /** @var bool */
  13. private $visited;
  14. /**
  15. * @param string $id
  16. * @param array $deps
  17. * @param bool $visited
  18. */
  19. public function __construct(string $id, array $deps = [], bool $visited = false) {
  20. $this->setId($id);
  21. $this->setDeps($deps);
  22. $this->setVisited($visited);
  23. }
  24. /**
  25. * @return string
  26. */
  27. public function getId(): string {
  28. return $this->id;
  29. }
  30. /**
  31. * @param string $id
  32. */
  33. public function setId(string $id): void {
  34. $this->id = $id;
  35. }
  36. /**
  37. * @return array
  38. */
  39. public function getDeps(): array {
  40. return $this->deps;
  41. }
  42. /**
  43. * @param array $deps
  44. */
  45. public function setDeps(array $deps): void {
  46. $this->deps = $deps;
  47. }
  48. /**
  49. * @param string $dep
  50. */
  51. public function addDep(string $dep): void {
  52. if (!in_array($dep, $this->deps, true)) {
  53. $this->deps[] = $dep;
  54. }
  55. }
  56. /**
  57. * @return bool
  58. */
  59. public function isVisited(): bool {
  60. return $this->visited;
  61. }
  62. /**
  63. * @param bool $visited
  64. */
  65. public function setVisited(bool $visited): void {
  66. $this->visited = $visited;
  67. }
  68. }