<?php

namespace Plainwork\Http;

class Redirect
{
    private string $path = '';
    private array $params = [];
    private array $messages = [];

    public function __construct(string $path, array $params = [])
    {
        $this->path = $path;
        $this->params = $params;
    }

    public function getPath(): string
    {
        return $this->path;
    }

    public function getParams(): array
    {
        return $this->params;
    }

    public function withParam(string $k, $v): self
    {
        $ret = clone $this;
        $ret->params[$k] = $v;

        return $ret;
    }

    public function withMessage(string $message)
    {
        $ret = clone $this;
        $ret->messages[] = $message;

        return $ret;
    }

    public function getMessages(): array
    {
        return $this->messages;
    }
}
