private function canInjectStrictDynamic(Header $header)
    {
        # check if a relevant directive exists
        if (
            $header->hasAttribute($directive = 'script-src')
            or $header->hasAttribute($directive = 'default-src')
        ) {
            if (
                preg_match(
                    "/(?:^|\s)(?:'strict-dynamic'|'none')(?:$|\s)/i",
                    $header->getAttributeValue($directive)
                )
            ) {
                return -1;
            }

            $nonceOrHashRe = implode(
                '|',
                array_map(
                    function ($s)
                    {
                        return preg_quote($s, '/');
                    },
                    array_merge(
                        ['nonce'],
                        $this->allowedCSPHashAlgs
                    )
                )
            );

            # if the directive contains a nonce or hash, return the directive
            # that strict-dynamic should be injected into
            $containsNonceOrHash = preg_match(
                "/(?:^|\s)'(?:$nonceOrHashRe)-/i",
                $header->getAttributeValue($directive)
            );

            if ($containsNonceOrHash)
            {
                return $directive;
            }
        }

        return false;
    }
private function canInjectStrictDynamic(Header $header)
    {
        # check if a relevant directive exists
        if (
            $header->hasAttribute($directive = 'script-src')
            or $header->hasAttribute($directive = 'default-src')
        ) {
            if (
                preg_match(
                    "/(?:^|\s)(?:'strict-dynamic'|'none')(?:$|\s)/i",
                    $header->getAttributeValue($directive)
                )
            ) {
                return -1;
            }

            $nonceOrHashRe = implode(
                '|',
                array_map(
                    function ($s)
                    {
                        return preg_quote($s, '/');
                    },
                    array_merge(
                        ['nonce'],
                        $this->allowedCSPHashAlgs
                    )
                )
            );

            # if the directive contains a nonce or hash, return the directive
            # that strict-dynamic should be injected into
            $containsNonceOrHash = preg_match(
                "/(?:^|\s)'(?:$nonceOrHashRe)-/i",
                $header->getAttributeValue($directive)
            );

            if ($containsNonceOrHash)
            {
                return $directive;
            }
        }

        return false;
    }
private function canInjectStrictDynamic ( Header $ header ) { # check if a relevant directive exists if ( $ header -> hasAttribute ( $ directive = 'script-src' ) or $ header -> hasAttribute ( $ directive = 'default-src' ) ) { if ( preg_match ( "/(?:^|\s)(?:'strict-dynamic'|'none')(?:$|\s)/i" , $ header -> getAttributeValue ( $ directive ) ) ) { return - 1 ; } $ nonceOrHashRe = implode ( '|' , array_map ( function ( $ s ) { return preg_quote ( $ s , '/' ) ; } , array_merge ( [ 'nonce' ] , $ this -> allowedCSPHashAlgs ) ) ) ; # if the directive contains a nonce or hash, return the directive # that strict-dynamic should be injected into $ containsNonceOrHash = preg_match ( "/(?:^|\s)'(?:$nonceOrHashRe)-/i" , $ header -> getAttributeValue ( $ directive ) ) ; if ( $ containsNonceOrHash ) { return $ directive ; } } return false ; }
Determine which directive `'strict-dynamic'` may be injected into, if
any.
If Safe-Mode conflicts, `-1` will be returned.
If `'strict-dynamic'` cannot be injected, `false` will be returned.

@return string|int|bool
Determine which directive strict - dynamic may be injected into if any . If Safe - Mode conflicts - 1 will be returned . If strict - dynamic cannot be injected false will be returned .