Test Failed
Pull Request — master (#88)
by Artem
04:05
created

ResolveIdentityProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 51
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 17 3
A __construct() 0 4 1
1
<?php
2
3
namespace Slides\Saml2\Http\Middleware;
4
5
use Illuminate\Http\Request;
0 ignored issues
show
Bug introduced by
The type Illuminate\Http\Request 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...
6
use Slides\Saml2\Exceptions\IdentityProviderNotFound;
7
use Slides\Saml2\Contracts\ResolvesIdentityProvider;
8
use Illuminate\Support\Facades\Log;
9
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpKe...n\NotFoundHttpException 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...
10
use Slides\Saml2\OneLoginBuilder;
11
12
class ResolveIdentityProvider
13
{
14
    /**
15
     * @var ResolvesIdentityProvider
16
     */
17
    protected ResolvesIdentityProvider $resolver;
18
19
    /**
20
     * @var OneLoginBuilder
21
     */
22
    protected OneLoginBuilder $builder;
23
24
    /**
25
     * ResolveTenant constructor.
26
     *
27
     * @param ResolvesIdentityProvider $resolver
28
     * @param OneLoginBuilder $builder
29
     */
30
    public function __construct(ResolvesIdentityProvider $resolver, OneLoginBuilder $builder)
31
    {
32
        $this->resolver = $resolver;
33
        $this->builder = $builder;
34
    }
35
36
    /**
37
     * Handle an incoming request.
38
     *
39
     * @param  \Illuminate\Http\Request  $request
40
     * @param  \Closure  $next
41
     *
42
     * @throws NotFoundHttpException
43
     *
44
     * @return mixed
45
     */
46
    public function handle(Request $request, \Closure $next)
47
    {
48
        if (!$idp = $this->resolver->resolve($request)) {
49
            throw new IdentityProviderNotFound();
50
        }
51
52
        if (config('saml2.debug')) {
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

52
        if (/** @scrutinizer ignore-call */ config('saml2.debug')) {
Loading history...
53
            Log::debug('[Saml2] Identity Provider resolved', [
54
                'uuid' => $idp->idpUuid()
55
            ]);
56
        }
57
58
        session()->flash('saml2.idp.uuid', $idp->idpUuid());
0 ignored issues
show
Bug introduced by
The function session 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

58
        /** @scrutinizer ignore-call */ 
59
        session()->flash('saml2.idp.uuid', $idp->idpUuid());
Loading history...
59
60
        $this->builder->configureIdp($idp);
61
62
        return $next($request);
63
    }
64
}
65