public function setState($newState)
    {
        if ($newState === $this->state) {
            return;
        }

        switch ($newState) {
            case self::STATE_RUNNING:
                $this->startedAt = new \DateTime();
                break;

            case self::STATE_FINISHED:
            case self::STATE_FAILED:
            case self::STATE_TERMINATED:
                $this->endedAt = new \DateTime();
                break;

            default:
                break;
        }

        $this->state = $newState;

        return $this;
    }
public function setState($newState)
    {
        if ($newState === $this->state) {
            return;
        }

        switch ($newState) {
            case self::STATE_RUNNING:
                $this->startedAt = new \DateTime();
                break;

            case self::STATE_FINISHED:
            case self::STATE_FAILED:
            case self::STATE_TERMINATED:
                $this->endedAt = new \DateTime();
                break;

            default:
                break;
        }

        $this->state = $newState;

        return $this;
    }
public function setState ( $ newState ) { if ( $ newState === $ this -> state ) { return ; } switch ( $ newState ) { case self :: STATE_RUNNING : $ this -> startedAt = new \ DateTime ( ) ; break ; case self :: STATE_FINISHED : case self :: STATE_FAILED : case self :: STATE_TERMINATED : $ this -> endedAt = new \ DateTime ( ) ; break ; default : break ; } $ this -> state = $ newState ; return $ this ; }
Set state.

@param bool $state
Set state .