AppScriptDependency.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2021, Jonas Meurer <jonas@freesources.org>
  4. *
  5. * @author Jonas Meurer <jonas@freesources.org>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace OC;
  24. class AppScriptDependency {
  25. /** @var string */
  26. private $id;
  27. /** @var array */
  28. private $deps;
  29. /** @var bool */
  30. private $visited;
  31. /**
  32. * @param string $id
  33. * @param array $deps
  34. * @param bool $visited
  35. */
  36. public function __construct(string $id, array $deps = [], bool $visited = false) {
  37. $this->setId($id);
  38. $this->setDeps($deps);
  39. $this->setVisited($visited);
  40. }
  41. /**
  42. * @return string
  43. */
  44. public function getId(): string {
  45. return $this->id;
  46. }
  47. /**
  48. * @param string $id
  49. */
  50. public function setId(string $id): void {
  51. $this->id = $id;
  52. }
  53. /**
  54. * @return array
  55. */
  56. public function getDeps(): array {
  57. return $this->deps;
  58. }
  59. /**
  60. * @param array $deps
  61. */
  62. public function setDeps(array $deps): void {
  63. $this->deps = $deps;
  64. }
  65. /**
  66. * @param string $dep
  67. */
  68. public function addDep(string $dep): void {
  69. if (!in_array($dep, $this->deps, true)) {
  70. $this->deps[] = $dep;
  71. }
  72. }
  73. /**
  74. * @return bool
  75. */
  76. public function isVisited(): bool {
  77. return $this->visited;
  78. }
  79. /**
  80. * @param bool $visited
  81. */
  82. public function setVisited(bool $visited): void {
  83. $this->visited = $visited;
  84. }
  85. }