ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Attribute.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\Export\ImportHandler\I\Path\Node\AttributeInterface as AttributeFilePathNodeInterface;
25
26class Attribute implements AttributeFilePathNodeInterface
27{
29 protected string $attribute;
30 protected bool $any_attribute_enabled;
31
32 public function __construct()
33 {
34 $this->attribute = '';
35 $this->any_attribute_enabled = false;
36 }
37
38 public function withAttribute(string $attribute): AttributeFilePathNodeInterface
39 {
40 $clone = clone $this;
41 $clone->attribute = $attribute;
42 return $clone;
43 }
44
45 public function withComparison(HandlerInterface $comparison): AttributeFilePathNodeInterface
46 {
47 $clone = clone $this;
48 $clone->comparison = $comparison;
49 return $clone;
50 }
51
52 public function withAnyAttributeEnabled(bool $enabled): AttributeFilePathNodeInterface
53 {
54 $clone = clone $this;
55 $clone->any_attribute_enabled = $enabled;
56 return $clone;
57 }
58
59 public function toString(): string
60 {
61 $attribute = $this->any_attribute_enabled
62 ? '@*'
63 : '@' . $this->attribute . (isset($this->comparison) ? $this->comparison->toString() : "");
64 return '[' . $attribute . ']';
65 }
66
67 public function requiresPathSeparator(): bool
68 {
69 return true;
70 }
71}
withComparison(HandlerInterface $comparison)
Definition: Attribute.php:45