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

RevertUrlSlug::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
crap 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