mirror of
https://github.com/leonelquinteros/php-toml.git
synced 2025-01-17 12:28:16 +01:00
Refactoring. Initial support for v0.3.0
This commit is contained in:
parent
5f9260a262
commit
f805a8a68a
18
src/toml.php
18
src/toml.php
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user