Pantheon\Terminus\Collections\Workflows::findLatestWithLogs PHP Method

findLatestWithLogs() public method

Get most-recent workflow from existing collection that has logs
public findLatestWithLogs ( ) : Workflow | null
return Workflow | null
    public function findLatestWithLogs()
    {
        $workflows = $this->allWithLogs();
        usort($workflows, function ($a, $b) {
            $a_finished_after_b = $a->get('finished_at') >= $b->get('finished_at');
            if ($a_finished_after_b) {
                $cmp = -1;
            } else {
                $cmp = 1;
            }
            return $cmp;
        });
        if (count($workflows) > 0) {
            $workflow = $workflows[0];
        } else {
            $workflow = null;
        }
        return $workflow;
    }