src/CSPBuilder.php
public static function fromFile(string $filename = ''): self
    {
        if (!\file_exists($filename)) {
            throw new \Exception($filename.' does not exist');
        }
        $contents = \file_get_contents($filename);
        if (!\is_string($contents)) {
            throw new \Exception('Could not read file contents');
        }
        return self::fromData($contents);
    }
public static function fromFile(string $filename = ''): self
    {
        if (!\file_exists($filename)) {
            throw new \Exception($filename.' does not exist');
        }
        $contents = \file_get_contents($filename);
        if (!\is_string($contents)) {
            throw new \Exception('Could not read file contents');
        }
        return self::fromData($contents);
    }
public static function fromFile ( string $ filename = '' ) : self { if ( ! \ file_exists ( $ filename ) ) { throw new \ Exception ( $ filename . ' does not exist' ) ; } $ contents = \ file_get_contents ( $ filename ) ; if ( ! \ is_string ( $ contents ) ) { throw new \ Exception ( 'Could not read file contents' ) ; } return self :: fromData ( $ contents ) ; }
Factory method - create a new CSPBuilder object from a JSON file

@param string $filename
@return self
@throws \Exception
Factory method - create a new CSPBuilder object from a JSON file