/** * convert an options array into an object * * @since 1.1 * @param array $values associative array * @return Facebook_Comments_Box comments box object */ public static function fromArray($values) { if (!is_array($values) || empty($values)) { return; } $comments_box = new Facebook_Comments_Box(); if (isset($values['href']) && is_string($values['href'])) { $comments_box->setURL($values['href']); } if (isset($values['width'])) { $comments_box->setWidth(absint($values['width'])); } if (isset($values['num_posts'])) { $comments_box->setNumPosts(absint($values['num_posts'])); } if (isset($values['colorscheme'])) { $comments_box->setColorScheme($values['colorscheme']); } if (isset($values['order_by'])) { $comments_box->setOrderBy($values['order_by']); } if (isset($values['mobile']) && ($values['mobile'] === true || $values['mobile'] === 'true' || $values['mobile'] == 1)) { $comments_box->forceMobile(); } return $comments_box; }