ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
In.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 class In implements Dependency
27 {
28  protected Name|string $name;
29  protected array $dependant = [];
30 
31  public function __construct(
32  protected InType $type,
33  string $name,
34  protected array $resolved_by = []
35  ) {
36  if ($type !== InType::INTERNAL) {
37  $name = new Name($name);
38  }
39  $this->name = $name;
40  }
41 
42  public function getName(): string
43  {
44  return (string) $this->name;
45  }
46 
47  public function __toString(): string
48  {
49  return $this->type->value . ": " . $this->name;
50  }
51 
52  public function getType(): InType
53  {
54  return $this->type;
55  }
56 
57  public function addDependant(Out $out): void
58  {
59  $this->dependant[(string) $out] = $out;
60  $out->addDependency($this);
61  }
62 
63  public function addResolution(Out $other): void
64  {
65  if ($this->type !== InType::SEEK && count($this->resolved_by) > 0) {
66  throw new LogicException(
67  "Dependency of type {$this->type} can only be resolved once."
68  );
69  }
70  $this->resolved_by[] = $other;
71  $other->addResolves($this);
72  }
73 
74  public function getResolvedBy(): array
75  {
76  return $this->resolved_by;
77  }
78 
79  public function resetResolutions(): void
80  {
81  $this->resolved_by = [];
82  }
83 }
$out
Definition: buildRTE.php:24
__construct(protected InType $type, string $name, protected array $resolved_by=[])
Definition: In.php:31
A dependency where the component needs something from the world.
Definition: In.php:26
A dependency where the component gives something to the world.
Definition: Out.php:26
addResolution(Out $other)
Definition: In.php:63