BeforeAuthUrlProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getRedirectUrl() 0 5 2
1
<?php
2
/**
3
 * Copyright (c) 2019. Volodymyr Hryvinskyi.  All rights reserved.
4
 * @author: <mailto:[email protected]>
5
 * @github: <https://github.com/hryvinskyi>
6
 */
7
8
declare(strict_types=1);
9
10
namespace Hryvinskyi\InvisibleCaptcha\Model\Provider\Failure\RedirectUrl;
11
12
use Hryvinskyi\InvisibleCaptcha\Model\Provider\Failure\RedirectUrlInterface;
13
use Magento\Customer\Model\Url;
14
use Magento\Framework\Session\SessionManagerInterface;
15
16
class BeforeAuthUrlProvider implements RedirectUrlInterface
17
{
18
    /**
19
     * @var SessionManagerInterface
20
     */
21
    private $sessionManager;
22
23
    /**
24
     * @var Url
25
     */
26
    private $url;
27
28
    /**
29
     * BeforeAuthUrlProvider constructor.
30
     *
31
     * @param SessionManagerInterface $sessionManager
32
     * @param Url $url
33
     */
34
    public function __construct(
35
        SessionManagerInterface $sessionManager,
36
        Url $url
37
    ) {
38
        $this->sessionManager = $sessionManager;
39
        $this->url = $url;
40
    }
41
42
    /**
43
     * Get redirection URL
44
     *
45
     * @return string
46
     */
47
    public function getRedirectUrl(): string
48
    {
49
        $beforeUrl = $this->sessionManager->getBeforeAuthUrl();
50
51
        return $beforeUrl ?: $this->url->getLoginUrl();
52
    }
53
}
54