SignedUrl   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 4
Bugs 2 Features 0
Metric Value
wmc 3
eloc 9
c 4
b 2
f 0
dl 0
loc 43
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sign() 0 5 2
A __construct() 0 5 1
1
<?php
2
3
namespace Spinzar\SignedUrl;
4
5
use Spatie\UrlSigner\MD5UrlSigner;
6
7
class SignedUrl extends MD5UrlSigner
8
{
9
    /**
10
     * The key that is used to generate secure signatures.
11
     *
12
     * @var string
13
     */
14
    protected $signatureKey;
15
16
    /**
17
     * The URL's query parameter name for the expiration.
18
     *
19
     * @var string
20
     */
21
    protected $expiresParameter;
22
23
    /**
24
     * The URL's query parameter name for the signature.
25
     *
26
     * @var string
27
     */
28
    protected $signatureParameter;
29
30
    public function __construct()
31
    {
32
        $this->signatureKey = config('signed-url.signatureKey');
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        $this->signatureKey = /** @scrutinizer ignore-call */ config('signed-url.signatureKey');
Loading history...
33
        $this->expiresParameter = config('signed-url.parameters.expires');
34
        $this->signatureParameter = config('signed-url.parameters.signature');
35
    }
36
37
    /**
38
     * Get a secure URL to a controller action.
39
     *
40
     * @param string             $url
41
     * @param \DateTime|int|null $expiration Defaults to the config value
42
     *
43
     * @return string
44
     */
45
    public function sign($url, $expiration = null)
46
    {
47
        $expiration = $expiration ? $expiration : config('signed-url.default_expiration_time_in_days');
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
        $expiration = $expiration ? $expiration : /** @scrutinizer ignore-call */ config('signed-url.default_expiration_time_in_days');
Loading history...
48
49
        return parent::sign($url, $expiration);
50
    }
51
}
52