Completed
Push — master ( 321b65...b2b8c6 )
by Freek
01:18
created

ProfileFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 14 3
1
<?php
2
3
namespace Spatie\Csp;
4
5
use Spatie\Csp\Exceptions\InvalidCspProfile;
6
use Spatie\Csp\Profiles\Profile;
7
8
class ProfileFactory
9
{
10
    public static function create(string $className): Profile
11
    {
12
        $profile = app($className);
13
14
        if (!is_a($profile, Profile::class, true)) {
15
            throw InvalidCspProfile::create($profile);
16
        }
17
18
        if (! empty(config('csp.report_uri'))) {
19
            $profile->reportTo(config('csp.report_uri'));
20
        }
21
22
        return $profile;
23
    }
24
}