Passed
Branch master (fbf0a6)
by Volodymyr
04:04
created

BeforeAuthUrlProvider::getRedirectUrl()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
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;
0 ignored issues
show
Bug introduced by
The type Magento\Customer\Model\Url was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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