Blame view

common/models/SlashRedirect.php 776 Bytes
9315e305   Anastasia   - slash redirect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  <?php
      
      namespace common\models;
      
      use artbox\core\models\interfaces\RedirectInterface;
      use yii\base\BaseObject;
      
      class SlashRedirect extends BaseObject implements RedirectInterface
      {
          /**
           * @var string
           */
          protected $link;
          
          /**
           * @param string $url
           *
           * @return bool
           */
          public function doRedirect(string $url): bool
          {
              if (substr($url, -1) === '/') {
                  $this->link = trim($url, '/');
                  return true;
              }
              return false;
          }
          
          /**
           * @return string
           */
          public function getLink(): string
          {
              return $this->link;
          }
      }