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

ProfileFactory::create()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1
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
}