Skip to content

Commit

Permalink
Merge pull request #13 from renanmpimentel/v1.x
Browse files Browse the repository at this point in the history
adding optional json string parameter from dynamic configuration
  • Loading branch information
paragonie-scott authored Nov 1, 2016
2 parents 736837d + 79708d5 commit e9a3cbf
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/CSPBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,23 @@ public static function fromFile($filename = '')
$array = \json_decode($json, true);
return new CSPBuilder($array);
}

/**
* Factory method - create a new CSPBuilder object from a JSON data
*
* @param string $data
* @return CSPBuilder
*/
public static function fromData($data = '')
{
$array = \json_decode($data, true);

if(!is_array($array)) {
throw new \Exception('Is not array valid');
}

return new CSPBuilder($array);
}

/**
* Get the formatted CSP header
Expand Down

0 comments on commit e9a3cbf

Please sign in to comment.