$metaJsonb * @return array{ * version: int, * policy_type: string, * subject_external_id: string, * odata_type: ?string, * etag: ?string, * scope_tag_ids: ?list, * assignment_target_count: ?int * } */ public function build(string $policyType, string $subjectExternalId, array $metaJsonb): array { $odataType = $metaJsonb['odata_type'] ?? null; $odataType = is_string($odataType) ? trim($odataType) : null; $odataType = $odataType !== '' ? $odataType : null; $etag = $metaJsonb['etag'] ?? null; $etag = is_string($etag) ? trim($etag) : null; $etag = $etag !== '' ? $etag : null; $scopeTagIds = $metaJsonb['scope_tag_ids'] ?? null; $scopeTagIds = is_array($scopeTagIds) ? $this->normalizeStringList($scopeTagIds) : null; $assignmentTargetCount = $metaJsonb['assignment_target_count'] ?? null; $assignmentTargetCount = is_numeric($assignmentTargetCount) ? (int) $assignmentTargetCount : null; return [ 'version' => self::VERSION, 'policy_type' => trim($policyType), 'subject_external_id' => trim($subjectExternalId), 'odata_type' => $odataType, 'etag' => $etag, 'scope_tag_ids' => $scopeTagIds, 'assignment_target_count' => $assignmentTargetCount, ]; } /** * @param array $values * @return list */ private function normalizeStringList(array $values): array { $values = array_values(array_filter($values, 'is_string')); $values = array_map('trim', $values); $values = array_values(array_filter($values, fn (string $value): bool => $value !== '')); $values = array_values(array_unique($values)); sort($values, SORT_STRING); return $values; } }