class Horde_Service_Gravatar { const STANDARD = 'http://www.gravatar.com'; const SECURE = 'https://secure.gravatar.com'; private $_base; public function __construct($base = self::STANDARD) { $this->_base = $base; } public function getId($mail) { if (!is_string($mail)) { throw new InvalidArgumentException('The mail address must be a string!'); } return md5(strtolower(trim($mail))); } public function getAvatarUrl($mail) { return $this->_base . '/avatar/' . $this->getId($mail); } public function getProfileUrl($mail) { return $this->_base . '/' . $this->getId($mail) . '.json'; } }