ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Builder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27
28class Builder implements BuilderInterface
29{
30 protected SlotIdentifier $slot;
31 protected Type $type;
32 protected string $id;
33 protected string $source;
34
38 protected array $values;
39 protected bool $is_active = true;
40 protected bool $allows_custom_inputs = true;
41
42 public function __construct(
43 SlotIdentifier $slot,
44 Type $type,
45 string $id,
46 string $source,
47 string ...$values
48 ) {
49 $this->slot = $slot;
50 $this->type = $type;
51 $this->id = $id;
52 $this->source = $source;
53 $this->values = $values;
54 }
55
56 public function withIsDeactivated(bool $deactivated = true): BuilderInterface
57 {
58 $clone = clone $this;
59 $clone->is_active = !$deactivated;
60 return $clone;
61 }
62
63 public function withDisallowsCustomInputs(bool $no_custom_inputs = true): BuilderInterface
64 {
65 $clone = clone $this;
66 $clone->allows_custom_inputs = !$no_custom_inputs;
67 return $clone;
68 }
69
70 public function get(): VocabularyInterface
71 {
72 return new Vocabulary(
73 $this->slot,
74 $this->type,
75 $this->id,
76 $this->source,
77 $this->is_active,
78 $this->allows_custom_inputs,
79 ...$this->values
80 );
81 }
82}
withIsDeactivated(bool $deactivated=true)
Definition: Builder.php:56
__construct(SlotIdentifier $slot, Type $type, string $id, string $source, string ... $values)
Definition: Builder.php:42
withDisallowsCustomInputs(bool $no_custom_inputs=true)
Definition: Builder.php:63