ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Out.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26class Out implements Dependency
27{
28 protected Name|string $name;
29 protected array $dependencies = [];
30 protected ?OfComponent $component = null;
31 protected array $resolves = [];
32
33 public function __construct(
34 protected OutType $type,
35 string $name,
36 // Helper field to be used to process specific type
37 public readonly mixed $aux,
38 array $dependencies
39 ) {
40 if ($type !== OutType::INTERNAL) {
41 $name = new Name($name);
42 }
43 $this->name = $name;
44 foreach ($dependencies as $d) {
45 $d->addDependant($this);
46 }
47 }
48
49 public function __toString(): string
50 {
51 return $this->type->value . ": " . $this->name;
52 }
53
54 public function getType(): OutType
55 {
56 return $this->type;
57 }
58
59 public function getName(): string
60 {
61 return (string) $this->name;
62 }
63
64 public function setComponent(OfComponent $component): void
65 {
66 if (!is_null($this->component)) {
67 throw new \LogicException(
68 "There already is a component here."
69 );
70 }
71 $this->component = $component;
72 }
73
74 public function getComponent(): OfComponent
75 {
76 if (is_null($this->component)) {
77 throw new \LogicException(
78 "There is no component here."
79 );
80 }
81
82 return $this->component;
83 }
84
85 public function addDependency(In $in): void
86 {
87 $this->dependencies[(string) $in] = $in;
88 }
89
90 public function getDependencies(): array
91 {
93 }
94
95 public function addResolves(In $in): void
96 {
97 $this->resolves[] = $in;
98 }
99
100 public function resetResolutions(): void
101 {
102 $this->resolves = [];
103 }
104}
A dependency where the component needs something from the world.
Definition: In.php:27
A dependency where the component gives something to the world.
Definition: Out.php:27
__construct(protected OutType $type, string $name, public readonly mixed $aux, array $dependencies)
Definition: Out.php:33
setComponent(OfComponent $component)
Definition: Out.php:64