<?php
    /**
     * Created by PhpStorm.
     * User: timur
     * Date: 22.11.17
     * Time: 11:54
     */
    
    namespace common\models;
    
    use artbox\core\models\interfaces\RedirectInterface;
    use yii\base\Object;
    
    class DirectRedirect extends Object implements RedirectInterface
    {
        
        protected $link;
        
        public function doRedirect(string $url): bool
        {
            $urlArray = array(
                '/site/index'   => '/ru',
                '/site/about'   => '/ru/about',
                '/site/contact' => '/ru/contact',
            );
            if (isset($urlArray[$url])){
                $this->link = $urlArray[$url];
                return true;
            }
            
            return false;
        }
        
        public function getLink(): string
        {
            return trim($this->link, "/");
        }
    }