|
|
|
|
@ -4,16 +4,34 @@ declare(strict_types=1); |
|
|
|
|
|
|
|
|
|
namespace prj\mockup\outputs\app; |
|
|
|
|
|
|
|
|
|
use \tts\safer_io as SafeIO; |
|
|
|
|
|
|
|
|
|
class home_out { |
|
|
|
|
|
|
|
|
|
public static function name_demo(array $input): array { |
|
|
|
|
$age = $input['html']['age']; |
|
|
|
|
$first_name = $input['html']['first_name'] ?? "Unknown"; |
|
|
|
|
$last_name = $input['html']['last_name'] ?? "Unknown"; |
|
|
|
|
|
|
|
|
|
$ret['main'] = ($input['errors']) ? "" : "Hello {$first_name} {$last_name}, You are {$age} years old!" . PHP_EOL; |
|
|
|
|
$ret['errors'] = $input['errors']; |
|
|
|
|
public static function name_demo(array & $input): array { |
|
|
|
|
$ret['model'] = $input['model']; |
|
|
|
|
unset($input['model']); // Required to work, as sanitize cannot take an Object |
|
|
|
|
|
|
|
|
|
$html_output = []; |
|
|
|
|
$errors = []; |
|
|
|
|
foreach(SafeIO::html_sanitize($input) as $html) { |
|
|
|
|
$key = $html['name'] ?? ""; |
|
|
|
|
$html_output[$key] = $html['html']; |
|
|
|
|
|
|
|
|
|
if (\tts\common::get_count($html['errors'])) { |
|
|
|
|
$errors[$key] = $html['errors'][$key]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$age = $html_output['age'] ?? 0; |
|
|
|
|
$first_name = $html_output['first_name'] ?? "Unknown"; |
|
|
|
|
$last_name = $html_output['last_name'] ?? "Unknown"; |
|
|
|
|
|
|
|
|
|
$ret['main'] = (\tts\common::get_count($errors)) ? "" : "Hello {$first_name} {$last_name}, You are {$age} years old!" . PHP_EOL; |
|
|
|
|
$ret['errors'] = $errors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unset($input); // Free up some space |
|
|
|
|
|
|
|
|
|
return $ret; |
|
|
|
|
} |
|
|
|
|
@ -37,7 +55,6 @@ class home_out { |
|
|
|
|
} |
|
|
|
|
\tts\html::show_table_from_generator( |
|
|
|
|
['ID', 'First Name', 'Last Name', 'Age'], |
|
|
|
|
['id', 'first_name', 'last_name', 'age'], |
|
|
|
|
$input |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|