Skip to content

Commit

Permalink
hotfix #378 - image & check for nullable friends_since [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
irfan-dahir committed Dec 25, 2021
1 parent 7d3fc1f commit 5cf72e1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Parser/User/Friends/FriendParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function getAvatar(): string
return str_replace(
['thumbs/', '_thumb'],
'',
$this->crawler->filterXPath('//div/a/img')->attr('src')
$this->crawler->filterXPath('//div/a/img')->attr('data-src')
);
}

Expand Down Expand Up @@ -79,8 +79,15 @@ public function getUrl(): string
public function getFriendsSince(): ?\DateTimeImmutable
{
$count = 0;
$text = $this->crawler->filterXPath('//div[last()]')->text();
$node = $this->crawler->filterXPath('//div[contains(@class, "data")]/div[3]');

if (!$node->count()) {
return null;
}

$text = JString::cleanse($node->text());
$text = preg_replace('/^Friends since (.*)$/', '$1', $text, -1, $count);

if (!$count) {
return null;
}
Expand Down

0 comments on commit 5cf72e1

Please sign in to comment.