Completed
Push — master ( b10c64...511a60 )
by Freek
02:20
created

Directive   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 6 1
1
<?php
2
3
namespace Spatie\Csp;
4
5
abstract class Directive
6
{
7
    const BASE = 'base-uri';
8
    const BLOCK_ALL_MIXED_CONTENT = 'block-all-mixed-content';
9
    const CHILD = 'child-src';
10
    const CONNECT = 'connect-src';
11
    const DEFAULT = 'default-src';
12
    const FONT = 'font-src';
13
    const FORM = 'form-action';
14
    const FRAME = 'frame-src';
15
    const FRAME_ANCESTORS = 'frame-ancestors';
16
    const IMG = 'img-src';
17
    const MANIFEST = 'manifest-src';
18
    const MEDIA = 'media-src';
19
    const OBJECT = 'object-src';
20
    const PLUGIN = 'plugin-types';
21
    const REPORT = 'report-uri';
22
    const SANDBOX = 'sandbox';
23
    const SCRIPT = 'script-src';
24
    const STYLE = 'style-src';
25
    const UPGRADE_INSECURE_REQUESTS = 'upgrade-insecure-requests';
26
    const WORKER = 'worker-src';
27
28
    public static function isValid(string $directive): bool
29
    {
30
        $constants = (new ReflectionClass(static::class))->getConstants();
31
32
        return in_array($directive, $constants);
33
    }
34
}
35