Completed
Push — dependabot/npm_and_yarn/tippy.... ( 40037f...deaa3c )
by
unknown
400:02 queued 379:38
created

RevertUrlSlug   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 14
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 4 2
A __construct() 0 3 1
1
<?php
2
3
namespace Thinktomorrow\Chief\Urls\Application;
4
5
use Thinktomorrow\Chief\Urls\UrlRecord;
6
use Thinktomorrow\Chief\Urls\UrlRecordNotFound;
7
use Thinktomorrow\Chief\Urls\ProvidesUrl\ProvidesUrl;
8
9
/**
10
 * Revert slug to most recent redirect or empty it when no redirect exists.
11
 */
12
class RevertUrlSlug
13
{
14
    /** @var ProvidesUrl */
15
    private $model;
16
17 1
    public function __construct(ProvidesUrl $model)
18
    {
19 1
        $this->model = $model;
20 1
    }
21
22 1
    public function handle(string $locale): void
23
    {
24 1
        if ($recentRedirect = UrlRecord::findRecentRedirect($this->model, $locale)) {
25 1
            $recentRedirect->revert();
26
        }
27 1
    }
28
}
29