mirror of
https://github.com/joelwmale/webhook-action.git
synced 2026-09-03 05:06:13 +08:00
update modules
This commit is contained in:
+9
-27
@@ -3,7 +3,7 @@
|
||||
/*!
|
||||
* ISC License
|
||||
*
|
||||
* Copyright (c) 2018-2020, Andrea Giammarchi, @WebReflection
|
||||
* Copyright (c) 2018-2021, Andrea Giammarchi, @WebReflection
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -60,7 +60,7 @@ class Flatted {
|
||||
}
|
||||
|
||||
// private helpers
|
||||
private static function asString(&$value) {
|
||||
private static function asString($value) {
|
||||
return $value instanceof FlattedString ? $value->value : $value;
|
||||
}
|
||||
|
||||
@@ -76,42 +76,25 @@ class Flatted {
|
||||
$obj = new ReflectionObject($value);
|
||||
$props = $obj->getProperties();
|
||||
$keys = array();
|
||||
foreach ($props as $prop) {
|
||||
foreach ($props as $prop)
|
||||
$keys[] = $prop->getName();
|
||||
}
|
||||
return $keys;
|
||||
}
|
||||
|
||||
private static function loop($obj, $keys, &$input, &$set, &$output) {
|
||||
foreach ($keys as $key) {
|
||||
$value = $obj ? $output->$key : $output[$key];
|
||||
if ($value instanceof FlattedString) {
|
||||
if ($value instanceof FlattedString)
|
||||
Flatted::ref($obj, $key, $input[$value->value], $input, $set, $output);
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
private static function relate(&$known, &$input, &$value) {
|
||||
if (is_string($value)) {
|
||||
if (is_string($value) || is_array($value) || is_object($value)) {
|
||||
$key = array_search($value, $known->key, true);
|
||||
if ($key !== false) {
|
||||
if ($key !== false)
|
||||
return $known->value[$key];
|
||||
}
|
||||
return Flatted::index($known, $input, $value);
|
||||
}
|
||||
if (is_array($value)) {
|
||||
$key = array_search($value, $known->key, true);
|
||||
if ($key !== false) {
|
||||
return $known->value[$key];
|
||||
}
|
||||
return Flatted::index($known, $input, $value);
|
||||
}
|
||||
if (is_object($value)) {
|
||||
$key = array_search($value, $known->key, true);
|
||||
if ($key !== false) {
|
||||
return $known->value[$key];
|
||||
}
|
||||
return Flatted::index($known, $input, $value);
|
||||
}
|
||||
return $value;
|
||||
@@ -137,7 +120,7 @@ class Flatted {
|
||||
private static function transform(&$known, &$input, &$value) {
|
||||
if (is_array($value)) {
|
||||
return array_map(
|
||||
function (&$value) use(&$known, &$input) {
|
||||
function ($value) use(&$known, &$input) {
|
||||
return Flatted::relate($known, $input, $value);
|
||||
},
|
||||
$value
|
||||
@@ -146,15 +129,14 @@ class Flatted {
|
||||
if (is_object($value)) {
|
||||
$object = new stdClass;
|
||||
$keys = Flatted::keys($value);
|
||||
foreach ($keys as $key) {
|
||||
foreach ($keys as $key)
|
||||
$object->$key = Flatted::relate($known, $input, $value->$key);
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
private static function wrap(&$value) {
|
||||
private static function wrap($value) {
|
||||
if (is_string($value)) {
|
||||
return new FlattedString($value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user