public function hpkp(
        $pins,
        $maxAge = null,
        $subdomains = null,
        $reportUri = null,
        $reportOnly = null
    ) {
        Types::assert(
            [
                'string|array' => [$pins],
                '?int|?string' => [$maxAge],
                '?string' => [$reportUri]
            ],
            [1, 2, 4]
        );

        $hpkp = &$this->getHPKPObject($reportOnly);

        # set single values

        if (isset($maxAge) or ! isset($this->hpkp['max-age']))
        {
            $hpkp['max-age'] = $maxAge;
        }

        if (isset($subdomains) or ! isset($this->hpkp['includesubdomains']))
        {
            $hpkp['includesubdomains']
                = (isset($subdomains) ? ($subdomains == true) : null);
        }

        if (isset($reportUri) or ! isset($this->hpkp['report-uri']))
        {
            $hpkp['report-uri'] = $reportUri;
        }

        if ( ! is_array($pins))
        {
            $pins = [$pins];
        }

        # set pins

        foreach ($pins as $key => $pin)
        {
            if (is_array($pin) and count($pin) === 2)
            {
                $res = array_intersect($pin, $this->allowedHPKPAlgs);

                if ( ! empty($res))
                {
                    $key = key($res);
                    $hpkp['pins'][] = [
                        $pin[($key + 1) % 2],
                        $pin[$key]
                    ];
                }
                else
                {
                    continue;
                }
            }
            elseif (
                is_string($pin) or (is_array($pin)
                and count($pin) === 1
                and ($pin = $pin[0]) !== false)
            ) {
                $hpkp['pins'][] = [$pin, 'sha256'];
            }
        }
    }
public function hpkp(
        $pins,
        $maxAge = null,
        $subdomains = null,
        $reportUri = null,
        $reportOnly = null
    ) {
        Types::assert(
            [
                'string|array' => [$pins],
                '?int|?string' => [$maxAge],
                '?string' => [$reportUri]
            ],
            [1, 2, 4]
        );

        $hpkp = &$this->getHPKPObject($reportOnly);

        # set single values

        if (isset($maxAge) or ! isset($this->hpkp['max-age']))
        {
            $hpkp['max-age'] = $maxAge;
        }

        if (isset($subdomains) or ! isset($this->hpkp['includesubdomains']))
        {
            $hpkp['includesubdomains']
                = (isset($subdomains) ? ($subdomains == true) : null);
        }

        if (isset($reportUri) or ! isset($this->hpkp['report-uri']))
        {
            $hpkp['report-uri'] = $reportUri;
        }

        if ( ! is_array($pins))
        {
            $pins = [$pins];
        }

        # set pins

        foreach ($pins as $key => $pin)
        {
            if (is_array($pin) and count($pin) === 2)
            {
                $res = array_intersect($pin, $this->allowedHPKPAlgs);

                if ( ! empty($res))
                {
                    $key = key($res);
                    $hpkp['pins'][] = [
                        $pin[($key + 1) % 2],
                        $pin[$key]
                    ];
                }
                else
                {
                    continue;
                }
            }
            elseif (
                is_string($pin) or (is_array($pin)
                and count($pin) === 1
                and ($pin = $pin[0]) !== false)
            ) {
                $hpkp['pins'][] = [$pin, 'sha256'];
            }
        }
    }
public function hpkp ( $ pins , $ maxAge = null , $ subdomains = null , $ reportUri = null , $ reportOnly = null ) { Types :: assert ( [ 'string|array' => [ $ pins ] , '?int|?string' => [ $ maxAge ] , '?string' => [ $ reportUri ] ] , [ 1 , 2 , 4 ] ) ; $ hpkp = & $ this -> getHPKPObject ( $ reportOnly ) ; # set single values if ( isset ( $ maxAge ) or ! isset ( $ this -> hpkp [ 'max-age' ] ) ) { $ hpkp [ 'max-age' ] = $ maxAge ; } if ( isset ( $ subdomains ) or ! isset ( $ this -> hpkp [ 'includesubdomains' ] ) ) { $ hpkp [ 'includesubdomains' ] = ( isset ( $ subdomains ) ? ( $ subdomains == true ) : null ) ; } if ( isset ( $ reportUri ) or ! isset ( $ this -> hpkp [ 'report-uri' ] ) ) { $ hpkp [ 'report-uri' ] = $ reportUri ; } if ( ! is_array ( $ pins ) ) { $ pins = [ $ pins ] ; } # set pins foreach ( $ pins as $ key => $ pin ) { if ( is_array ( $ pin ) and count ( $ pin ) === 2 ) { $ res = array_intersect ( $ pin , $ this -> allowedHPKPAlgs ) ; if ( ! empty ( $ res ) ) { $ key = key ( $ res ) ; $ hpkp [ 'pins' ] [ ] = [ $ pin [ ( $ key + 1 ) % 2 ] , $ pin [ $ key ] ] ; } else { continue ; } } elseif ( is_string ( $ pin ) or ( is_array ( $ pin ) and count ( $ pin ) === 1 and ( $ pin = $ pin [ 0 ] ) !== false ) ) { $ hpkp [ 'pins' ] [ ] = [ $ pin , 'sha256' ] ; } } }
Add and configure the HTTP Public Key Pins header.

@param string|array $pins
Either give a valid pin as a string here, or give multiple as an array.
**Note that browsers will not enforce this header unless a backup pin
AND a pin that is currently deployed is specified)**. This means that
at least two pins must be specified. (to do this by passing strings,
simply call {@see hpkp} again with the second pin as the first
argument).

Valid array syntax is as follows
```php
$pins = array(
array('sha256', 'pin1'),
array('pin2'),
array('pin3', 'sha256')
);
$headers->hpkp($pins);
```

The above will add `pin1`, `pin2`, and `pin3` with the associated hash
label `sha256`. This is the only valid *  HPKP hashing algorithm at
time of writing.

@api

@param ?integer|string $maxAge
The length, in seconds that a browser should enforce the policy after
last receiving it.

If this is left unset across all calls to  {@see hpkp}, the value will
default to 10 seconds (which isn't much use – so it is best to set the
value).

Passing `null` indicates that a maxAge should not be modified on this
call (e.g. can be used to prevent overwriting a previous setting).

@param ?mixed $subdomains
Loosely casted to a boolean, whether to include the `includeSubDomains`
flag to deploy the policy across the entire domain. `true` enables this
flag.

Passing `null` indicates that a subdomains should not be modified on
this call (e.g. can be used to prevent overwriting a previous setting).

@param ?string $reportUri
A reporting address to send violation reports to.

Passing `null` indicates that a reporting address should not be modified
on this call (e.g. can be used to prevent overwriting a previous
setting).

@param mixed $reportOnly
Loosely cased to a boolean. If `true`, settings will apply to the
report-only version of this header.

@return void
Add and configure the HTTP Public Key Pins header .