src/CSPBuilder.php
public function addDirective(string $key, $value = null): self
    {
        if ($value === null) {
            if (!isset($this->policies[$key])) {
                $this->policies[$key] = true;
            }
        } elseif (empty($this->policies[$key])) {
            $this->policies[$key] = $value;
        }
        return $this;
    }
public function addDirective(string $key, $value = null): self
    {
        if ($value === null) {
            if (!isset($this->policies[$key])) {
                $this->policies[$key] = true;
            }
        } elseif (empty($this->policies[$key])) {
            $this->policies[$key] = $value;
        }
        return $this;
    }
public function addDirective ( string $ key , $ value = null ) : self { if ( $ value === null ) { if ( ! isset ( $ this -> policies [ $ key ] ) ) { $ this -> policies [ $ key ] = true ; } } elseif ( empty ( $ this -> policies [ $ key ] ) ) { $ this -> policies [ $ key ] = $ value ; } return $ this ; }
Add a directive if it doesn't already exist

If it already exists, do nothing

@param string $key
@param mixed $value

@return self
Add a directive if it doesn t already exist