SimpleUrlProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 41
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getRedirectUrl() 0 3 1
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\Framework\UrlInterface;
14
15
class SimpleUrlProvider implements RedirectUrlInterface
16
{
17
    /**
18
     * @var string
19
     */
20
    private $urlPath;
21
22
    /**
23
     * @var array
24
     */
25
    private $urlParams;
26
27
    /**
28
     * @var UrlInterface
29
     */
30
    private $url;
31
32
    /**
33
     * SimpleUrlProvider constructor.
34
     *
35
     * @param UrlInterface $url
36
     * @param string $urlPath
37
     * @param null|array $urlParams
38
     */
39
    public function __construct(
40
        UrlInterface $url,
41
        string $urlPath,
42
        $urlParams = null
43
    ) {
44
        $this->urlPath = $urlPath;
45
        $this->urlParams = $urlParams;
46
        $this->url = $url;
47
    }
48
49
    /**
50
     * Get redirection URL
51
     * @return string
52
     */
53
    public function getRedirectUrl(): string
54
    {
55
        return $this->url->getUrl($this->urlPath, $this->urlParams);
56
    }
57
}
58