added completness check
Some checks failed
PHP_CodeSniffer / phpcs (push) Failing after 3m59s
Unit Testing / phpunit (5.6, 6.2) (push) Failing after 4m24s
Unit Testing / phpunit (7.0) (push) Failing after 4m36s
Unit Testing / phpunit (7.2) (push) Failing after 4m28s
Unit Testing / phpunit (7.3) (push) Failing after 5m23s
Unit Testing / phpunit (7.4) (push) Failing after 5m22s
Unit Testing / phpunit (8.0) (push) Failing after 5m34s
Unit Testing / phpunit (8.1) (push) Failing after 5m35s
Unit Testing / phpunit (8.2) (push) Failing after 5m52s
Unit Testing / phpunit (latest) (push) Failing after 5m21s

This commit is contained in:
ruru4143 2023-12-11 23:22:19 +01:00
parent 5cc9c35811
commit a626dfce4e

View file

@ -746,5 +746,37 @@ class Base_Object {
return $this; return $this;
} }
public function check_jsonld_completeness() {
// Just a debugging helper function
$vars = get_object_vars( $this );
$total_var_count = count( $vars );
$unset_var_array = array();
foreach ( $vars as $key => $value ) {
// ignore all _prefixed keys.
if ( '_' === substr( $key, 0, 1 ) ) {
--$total_var_count;
continue;
}
// if value is empty, try to get it from a getter.
if ( ! $value ) {
$value = call_user_func( array( $this, 'get_' . $key ) );
}
// if value is still empty, ignore it for the array and continue.
if ( ! isset( $value ) ) {
$unset_var_array[] = $key;
}
}
$unset_var_count = count( $unset_var_array );
return array(
'total_var_count' => $total_var_count,
'unset_var_count' => $unset_var_count,
'set_var_count' => $total_var_count - $unset_var_count,
'unset_vars' => $unset_var_array,
);
}
} }