ignore prefixed attributes

This commit is contained in:
Matthias Pfefferle 2023-06-28 19:38:19 +02:00
parent 75a77b3f5c
commit 1fe8c26b1d

View file

@ -462,6 +462,24 @@ class Base_Object {
}
}
/**
* Magic function, to transform the object to string.
*
* @return string The object id.
*/
public function __toString() {
return $this->to_string();
}
/**
* Function to transform the object to string.
*
* @return string The object id.
*/
public function to_string() {
return $this->get_id();
}
/**
* Generic getter.
*
@ -575,6 +593,11 @@ class Base_Object {
$vars = get_object_vars( $this );
foreach ( $vars as $key => $value ) {
// ignotre all _prefixed keys.
if ( '_' === substr( $key, 0, 1 ) ) {
continue;
}
// if value is empty, try to get it from a getter.
if ( ! isset( $value ) ) {
$value = call_user_func( array( $this, 'get_' . $key ) );