transform( static function (array|SmartPlaylistRule $rule): SmartPlaylistRule { return $rule instanceof SmartPlaylistRule ? $rule : SmartPlaylistRule::make($rule); } ), ); } /** @return array */ public function toArray(): array { return [ 'id' => $this->id, 'rules' => $this->rules->toArray(), ]; } }