public function testAvatarUrl() { $url = 'http://www.example.com/image.jpg'; $profile = new Profile(); $profile->setAvatarUrl($url); $this->assertEquals($url, $profile->getAvatarUrl()); }
public static function parse($contents, $apiVersion) { $user = new Profile(); $crawler = new Crawler(); $crawler->addHTMLContent($contents, 'UTF-8'); $profileContent = $crawler->filter('#contentWrapper'); $avatar = $profileContent->filter('.user-image img'); if ($avatar->count() > 0) { $user->setAvatarUrl($avatar->attr('src')); } $animeStats = $profileContent->filter('.stats')->filter('.anime'); $mangaStats = $profileContent->filter('.stats')->filter('.manga'); $user->details = self::parseDetails($profileContent, $user->details, $apiVersion); //Details is an object, so we need to pass it to the function. $user->anime_stats = self::parseStats($animeStats, $user->anime_stats, 'anime', $apiVersion); $user->manga_stats = self::parseStats($mangaStats, $user->manga_stats, 'manga', $apiVersion); return $user; }