Pantheon\Terminus\Models\Workflow::serialize PHP Method

serialize() public method

Formats workflow object into an associative array for output
public serialize ( ) : array
return array Associative array of data for output
    public function serialize()
    {
        $user = 'Pantheon';
        if (isset($this->get('user')->email)) {
            $user = $this->get('user')->email;
        }
        if ($this->get('total_time')) {
            $elapsed_time = $this->get('total_time');
        } else {
            $elapsed_time = time() - $this->get('created_at');
        }
        $operations_data = [];
        foreach ($this->operations() as $operation) {
            $operations_data[] = $operation->serialize();
        }
        $data = ['id' => $this->id, 'env' => $this->get('environment'), 'workflow' => $this->get('description'), 'user' => $user, 'status' => $this->getStatus(), 'time' => sprintf("%ds", $elapsed_time), 'operations' => $operations_data];
        return $data;
    }