$value ) { if ( ! property_exists( $item, $key ) ) { continue; } switch ( $key ) { case 'id': case 'source_id': case 'size_bytes': case 'attempts': $item->$key = (int) $value; break; case 'meta': $decoded = $value ? json_decode( (string) $value, true ) : []; $item->meta = is_array( $decoded ) ? $decoded : []; break; default: $item->$key = (string) $value; } } return $item; } public function is_synced(): bool { return self::SYNCED === $this->status; } public function is_private(): bool { return 'private' === $this->visibility; } public function filename(): string { $name = $this->meta['filename'] ?? ''; return '' !== $name ? $name : wp_basename( '' !== $this->local_path ? $this->local_path : $this->object_key ); } public function to_array(): array { return [ 'id' => $this->id, 'source_type' => $this->source_type, 'source_id' => $this->source_id, 'variant' => $this->variant, 'provider' => $this->provider, 'bucket' => $this->bucket, 'object_key' => $this->object_key, 'visibility' => $this->visibility, 'mime_type' => $this->mime_type, 'size_bytes' => $this->size_bytes, 'status' => $this->status, 'local_state' => $this->local_state, 'attempts' => $this->attempts, 'last_error' => $this->last_error, 'filename' => $this->filename(), 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, ]; } }