19 declare(strict_types=1);
41 foreach ($this->fields as $field) {
48 if (!is_object($data)) {
49 return fn() => yield
"Expected an object.";
52 $repr = new \StdClass();
55 foreach ($this->fields as $field) {
56 $name = $field->getName();
60 if (method_exists($data, $method)) {
62 $value = $data->$method();
68 if (property_exists($data, $property)) {
70 $value = $data->$property;
76 $errors[] = fn() => yield
"Object does not have property \"$name\".";
80 $value = $field->getType()->getPrimitiveRepresentation($value);
81 if ($value instanceof \
Closure) {
84 $repr->$name = $value;
91 return $this->mergeErrors($errors);
102 yield
"get" . ucfirst($name);
103 yield
"get_" . $name;
104 yield
"get" . $camel_cased;
105 yield
"get_" . $snake_cased;
106 yield
"is" . ucfirst($name);
108 yield
"is" . $camel_cased;
109 yield
"is_" . $snake_cased;
115 yield ucfirst($name);
123 return preg_replace_callback(
"/_(\w)/", fn($v) => strtoupper($v[1]), $name);
128 return preg_replace_callback(
"/[A-Z]/", fn($v) =>
"_" . strtolower($v[0]), $name);
getPrimitiveRepresentation(mixed $data)
possiblePropertyNames(string $name)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This describes some datastructure in terms of standard data structures such as primitives, lists, maps and objects and helpful (hopefully...) human readable texts.
__construct(Text\SimpleDocumentMarkdown $description, Field ... $fields)
possibleMethodNames(string $name)
__construct(Container $dic, ilPlugin $plugin)