Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
#45 Add isJson helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Kleinhans committed Dec 13, 2016
1 parent 584ac60 commit f8602ea
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/StackFormation/Helper/Div.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,17 @@ public static function isProgramInstalled($program)
@exec('which ' . $program, $out, $return);
return $return === 0;
}

/**
* @param string $string
* @return bool
*/
public static function isJson($string) {
$string = trim($string);

// TODO just a workaround to check if the string is a valid JSON
// we could not check that with json_decode because, it could be that the JSON file has some comments inside
// and the StringPreProcessor/StripComments is invoked after that check!!
return preg_match('/\A\{(.*)/', $string);
}
}

0 comments on commit f8602ea

Please sign in to comment.