Refactoring. Initial support for v0.3.0

This commit is contained in:
Leonel Quinteros 2014-11-11 11:15:42 -02:00
parent 5f9260a262
commit f805a8a68a
2 changed files with 20 additions and 8 deletions

View File

@ -313,7 +313,6 @@ class Toml
// String
elseif($val[0] == '"' && substr($val, -1) == '"')
{
// $parsedVal = str_replace(array('\0', '\t', '\n', '\r', '\"', '\\') , array("\0", "\t", "\n", "\r", '"', "\\"), substr($val, 1, -1));
// TOML's specification says it's the same as for JSON format... so
$parsedVal = json_decode($val);
}
@ -430,7 +429,6 @@ class Toml
*/
private static function checkDataType($array)
{
if(count($array) <= 1)
{
return true;
@ -448,7 +446,6 @@ class Toml
{
return true;
}
}
/**
@ -459,8 +456,6 @@ class Toml
*/
private static function getCustomDataType($val)
{
//$val = (!is_array($val)) ? trim($val) : $val;
if (!is_array($val))
{
$type = "date";
@ -481,7 +476,16 @@ class Toml
*/
private static function isISODate($val)
{
return preg_match('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/', $val);
}
// Use DateTime support to check for valid dates.
try
{
$date = new DateTime($val);
}
catch(Exception $e)
{
return false;
}
return true;
}
}

View File

@ -7,7 +7,7 @@ crazy-string = "With a comment # inside, escaped quotes \" and [brackets]"
name = "Tom Preston-Werner"
organization = "GitHub"
bio = "GitHub Cofounder & CEO\nLikes tater tots and beer."
dob = 1979-05-27T07:32:00Z # First class dates? Why not?
dob = 1979-05-27T00:32:00.999999-07:00 # First class dates? Why not?
[database]
server = "192.168.1.1"
@ -48,3 +48,11 @@ hosts = [
"alpha # Try this hash", # Comment here, after string hash.
"omega",
]
[version030.floats]
fractional = [ +1.0, 3.1415, -0.01 ]
exponent = [ 5e+22, 1e6, -2E-2 ]
both = 6.626e-34