*/ class Wp_Database_Tools_Database_Data_Author { /** * The id of the Author. * * @since 1.0.0 * @access protected * @var string $id The id of the Author. */ protected $id; /** * The name of the Author. * * @since 1.0.0 * @access protected * @var string $name The name of the Author. */ protected $name; /** * The url of the Author. * * @since 1.0.0 * @access protected * @var string $url The name of the Author. */ protected $url; /** * Constructor * * Create the instance of a Author. * * @access public * @since 1.0.0 */ public function __construct() { $this->id = str_shuffle( 'abcdefABCDEF' ) . '-' . rand( 1000, 2000 ); $this->name = 'Unknown'; $this->url = null; } /** * Set object attributes via API information * * @access public * @since 1.0.0 * * @param Object $api_data Object obtained from API information. */ public function set_author_by_api( $api_data ) { $this->id = $api_data->id; $this->name = $api_data->author ?? $api_data->user_nicname ?? null; $this->url = $api_data->profile ?? $api_data->author_url ?? null; } /** * Set object attributes via algorithm * * @access public * @since 1.0.0 * * @param Array $algorithm_data Array returning the identification algorithm. */ public function set_author_by_algorithm( $algorithm_data ) { $this->name = $data_algorithm['author'] ?? $data_algorithm['author_name'] ?? null; $this->url = $data_algorithm['author_url'] ?? null; } /** * Return attributes as an array * * @access public * @since 1.0.0 * * @return Array Array attributes. */ public function return_object_vars() { return get_object_vars( $this ); } }