Skip to content

Commit e8b4862

Browse files
committed
Update class doc block
1 parent 25284f4 commit e8b4862

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

src/ValueObject/ArrayFactory.php

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,128 @@
2929
* This file creates node visitors for a value object of type string.
3030
*
3131
* The following code will be generated:
32+
*
33+
* private int $position = 0;
34+
*
35+
* private array $items;
36+
*
37+
* public function rewind() : void
38+
* {
39+
* $this->position = 0;
40+
* }
41+
*
42+
* public function current() : ReasonType
43+
* {
44+
* return $this->items[$this->position];
45+
* }
46+
*
47+
* public function key() : int
48+
* {
49+
* return $this->position;
50+
* }
51+
*
52+
* public function next() : void
53+
* {
54+
* ++$this->position;
55+
* }
56+
*
57+
* public function valid() : bool
58+
* {
59+
* return isset($this->items[$this->position]);
60+
* }
61+
*
62+
* public function count() : int
63+
* {
64+
* return count($this->items);
65+
* }
66+
*
67+
* public static function fromArray(array $items) : self
68+
* {
69+
* return new self(...array_map(static function (string $item) {
70+
* return ReasonType::fromString($item);
71+
* }, $items));
72+
* }
73+
*
74+
* public static function fromItems(ReasonType ...$items) : self
75+
* {
76+
* return new self(...$items);
77+
* }
78+
*
79+
* public static function emptyList() : self
80+
* {
81+
* return new self();
82+
* }
83+
*
84+
* private function __construct(ReasonType ...$items)
85+
* {
86+
* $this->items = $items;
87+
* }
88+
*
89+
* public function add(ReasonType $reasonType) : self
90+
* {
91+
* $copy = clone $this;
92+
* $copy->items[] = $reasonType;
93+
* return $copy;
94+
* }
95+
*
96+
* public function remove(ReasonType $reasonType) : self
97+
* {
98+
* $copy = clone $this;
99+
* $copy->items = array_values(array_filter($copy->items, static function ($v) {
100+
* return !$v->equals($reasonType);
101+
* }));
102+
* return $copy;
103+
* }
104+
*
105+
* public function first() : ?ReasonType
106+
* {
107+
* return $this->items[0] ?? null;
108+
* }
109+
*
110+
* public function last() : ?ReasonType
111+
* {
112+
* if (count($this->items) === 0) {
113+
* return null;
114+
* }
115+
* return $this->items[count($this->items) - 1];
116+
* }
117+
*
118+
* public function contains(ReasonType $reasonType) : bool
119+
* {
120+
* foreach ($this->items as $existingItem) {
121+
* if ($existingItem->equals($reasonType)) {
122+
* * return true;
123+
* }
124+
* }
125+
* return false;
126+
* }
127+
*
128+
* public function filter(callable $filter) : self
129+
* {
130+
* return new self(...array_values(array_filter($this->items, static function ($v) {
131+
* return $filter($v);
132+
* })));
133+
* }
134+
*
135+
* public function items() : array
136+
* {
137+
* return $this->items;
138+
* }
139+
*
140+
* public function toArray() : array
141+
* {
142+
* return \array_map(static function (ReasonType $reasonType) {
143+
* return $reasonType->toArray();
144+
* }, $this->items);
145+
* }
146+
*
147+
* public function equals($other) : bool
148+
* {
149+
* if (!$other instanceof self) {
150+
* return false;
151+
* }
152+
* return $this->toArray() === $other->toArray();
153+
* }
32154
*/
33155
final class ArrayFactory
34156
{

0 commit comments

Comments
 (0)