You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: controller.go
    path of file: ./repos/chaos-mesh/controllers/common/desiredphase
    
    the code of the file until where you have to start completion: // Copyright 2021 Chaos Mesh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agr
    
func (info *reconcileInfo) CalcDesiredPhase() (v1alpha1.DesiredPhase, []recorder.ChaosEvent) {
	events := []recorder.ChaosEvent{}

	// Consider the finalizers
	if info.obj.IsDeleted() {
		if info.obj.GetStatus().Experiment.DesiredPhase != v1alpha1.StoppedPhase {
			events = append(events, recorder.Deleted{})
		}
		return v1alpha1.StoppedPhase, events
	}

	if info.obj.IsOneShot() {
		// An oneshot chaos should always be in running phase, so that it cannot
		// be applied multiple times or cause other bugs :(
		return v1alpha1.RunningPhase, events
	}

	// Consider the duration
	now := time.Now()

	durationExceeded, untilStop, err := info.obj.DurationExceeded(now)
	if err != nil {
		info.Log.Error(err, "failed to parse duration")
	}
	if durationExceeded {
		if info.obj.GetStatus().Experiment.DesiredPhase != v1alpha1.StoppedPhase {
			events = append(events, recorder.TimeUp{})
		}
		return v1alpha1.StoppedPhase, events
	}

	info.requeueAfter = untilStop

	// Then decide the pause logic
	if info.obj.IsPaused() {
		if info.obj.GetStatus().Experiment.DesiredPhase != v1alpha1.StoppedPhase {
			events = append(events, recorder.Paused{})
		}
		return v1alpha1.StoppedPhase, events
	}

	if info.obj.GetStatus().Experiment.DesiredPhase != v1alpha1.RunningPhase {
		events = append(events, recorder.Started{})
	}
	return v1alpha1.RunningPhase, events
}