FoundationServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerRequestSignatureValidation() 0 16 1
A register() 0 3 1
1
<?php
2
3
namespace Endeavors\Components\Routing;
4
5
use Illuminate\Routing\Redirector;
6
use Illuminate\Support\ServiceProvider;
7
use Illuminate\Http\Request;
8
use Illuminate\Support\Facades\URL;
9
10
class FoundationServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Register the service provider.
14
     *
15
     * @return void
16
     */
17
    public function register()
18
    {
19
        $this->registerRequestSignatureValidation();
20
    }
21
22
    /**
23
     * Register the signature macros on the request.
24
     * @todo is URL::getRequest the same as $this
25
     * @return void
26
     */
27
    public function registerRequestSignatureValidation()
28
    {
29
        Request::macro('hasValidSignature', function() {
30
            return URL::hasValidSignature($this ?? URL::getRequest());
31
        });
32
33
        Request::macro('hasInvalidSignature', function() {
34
            return !URL::hasValidSignature($this ?? URL::getRequest());
35
        });
36
37
        Request::macro('hasValidParameterSignature', function(array $parameters = []) {
38
            return URL::hasValidParameterSignature($this ?? URL::getRequest(), $parameters);
39
        });
40
41
        Request::macro('hasInvalidParameterSignature', function(array $parameters = []) {
42
            return !URL::hasValidParameterSignature($this ?? URL::getRequest(), $parameters);
43
        });
44
    }
45
}
46