id = (int) $array['id']; $hasMembers = isset($array['members']); if ($hasMembers) { $items = $array['members']; foreach ($items as $item) { $member = Member::createFromArray($item); $instance->members[] = $member; } } $hasTags = isset($array['tags']); if ($hasTags) { $items = $array['tags']; foreach ($items as $itemKey => $itemValue) { $tag = Tag::createFromValues($itemKey, $itemValue); $instance->tags[] = $tag; } } $instance->completeFromArray($array); return $instance; } public function completeFromArray(array $array): static { return $this; } public function getTagValue(string $key): ?string { $foundTags = array_filter($this->tags, function ($tag) use ($key) { return $tag->key === $key; }); if (count($foundTags) !== 1) { return null; } $tag = reset($foundTags); return $tag->value; } }