Completed
Push — dependabot/npm_and_yarn/vue-se... ( e78fac...845b60 )
by
unknown
358:07 queued 338:52
created

RevertUrlSlug::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

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