Skip to content

Commit 6694a92

Browse files
authored
Merge pull request #17 from RPGLogs/to-upstream
Fix server/DC parsing, allow multi-line bio, allow missing server for linkshell
2 parents bfac8f4 + 20e5113 commit 6694a92

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

Diff for: src/Lodestone/Parser/HelpersTrait.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,10 @@ public function getTimestamp($node)
3232

3333
public function getServerAndDc($line)
3434
{
35-
$line = trim($line);
36-
37-
// this has a very special space, its not a " " normal space
38-
// its a " " space, whatever the fuck that is
39-
$server = trim(explode(" ", $line)[0]);
40-
$dc = trim(explode(" ", $line)[1]);
41-
$dc = str_ireplace(['(',')'], null, $dc);
42-
35+
$parts = explode(' ', $line, 2);
36+
$server = trim($parts[0]);
37+
$dc = trim($parts[1] ?? '', '[]');
38+
4339
return [
4440
$server,
4541
$dc

Diff for: src/Lodestone/Parser/ParseCharacter.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ private function parseProfileBasic()
252252
*/
253253
private function parseProfileBio()
254254
{
255-
$bio = $this->dom->find('.character__selfintroduction')->text();
255+
$bio = $this->dom->find('.character__selfintroduction')->html();
256+
$bio = str_replace(['<br>', '<br />', '<br/>'], "\n", $bio);
256257
$bio = html_entity_decode($bio, ENT_QUOTES, "UTF-8");
257258
$bio = str_ireplace('Character Profile', null, $bio);
258259

Diff for: src/Lodestone/Parser/ParseLinkshellMembers.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function handle(string $html)
2525
// set linkshell name
2626
$this->list->Profile = (Object)[
2727
'Name' => trim($namedata[0]),
28-
'Server' => trim($namedata[1])
28+
'Server' => trim($namedata[1] ?? '')
2929
];
3030

3131
// parse list

Diff for: tests

+13-9
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,21 @@ $api = new \Lodestone\Api();
3636
$user = '9575452';
3737
$expectedUserName = 'Arcane Disgea';
3838
$fc = '9232379236109629819';
39-
$expectedfc = 'Hell Hath No Fury';
39+
$expectedfc = 'Hell On Aura';
4040
$ls = '18014398509568031';
4141
$pvp = '59665d98bf81ff58db63305b538cd69a6c64d578';
42+
$bio = "This is a test of the emergency alert system.\nAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH";
4243

4344
echo "-- RUNNING TESTS --\n";
44-
Assert::assertSame($api->character()->get($user)->Name, $expectedUserName);
45+
$character = $api->character()->get($user);
46+
Assert::assertSame($expectedUserName, $character->Name);
47+
Assert::assertSame($bio, $character->Bio);
48+
4549
Assert::assertNotEmpty($api->character()->friends($user));
4650
Assert::assertNotEmpty($api->character()->following($user));
4751
// Assert::assertTrue($api->character()->achievements($user)->PointsTotal > 0); AHHHHHHHHHHHHHHHH
4852
// Assert::assertNotEmpty($api->getCharacterAchievementsFull($user)->Achievements); This may not be relevant anymore
49-
Assert::assertSame($api->FreeCompany()->get($fc)->Name, $expectedfc);
53+
Assert::assertSame($expectedfc, $api->FreeCompany()->get($fc)->Name);
5054
// Assert::assertSame($api->getFreeCompanyFull('9233927348481473031')->Profile->ID, '9233927348481473031'); This may not be relevant anymore
5155
Assert::assertNotEmpty($api->FreeCompany()->members($fc)->Results);
5256
Assert::assertNotEmpty($api->Linkshell()->get($ls)->Results);
@@ -56,12 +60,12 @@ Assert::assertNotEmpty($api->FreeCompany()->search('a')->Results);
5660
Assert::assertNotEmpty($api->Linkshell()->search('a')->Results);
5761
Assert::assertNotEmpty($api->PvPTeam()->search('a')->Results);
5862
Assert::assertNotEmpty($api->lodestone()->banners());
59-
Assert::assertNotEmpty($api->lodestone()->News());
60-
Assert::assertNotEmpty($api->lodestone()->Topics());
61-
Assert::assertNotEmpty($api->lodestone()->Notices());
62-
Assert::assertNotEmpty($api->lodestone()->Maintenance());
63-
Assert::assertNotEmpty($api->lodestone()->Updates());
64-
Assert::assertNotEmpty($api->lodestone()->Status());
63+
//Assert::assertNotEmpty($api->lodestone()->News());
64+
//Assert::assertNotEmpty($api->lodestone()->Topics());
65+
//Assert::assertNotEmpty($api->lodestone()->Notices());
66+
//Assert::assertNotEmpty($api->lodestone()->Maintenance());
67+
//Assert::assertNotEmpty($api->lodestone()->Updates());
68+
//Assert::assertNotEmpty($api->lodestone()->Status());
6569
Assert::assertNotEmpty($api->lodestone()->WorldStatus());
6670
Assert::assertNotEmpty($api->devposts()->blog());
6771
# Assert::assertNotEmpty($api->getDevPosts()); - this takes agessssss

0 commit comments

Comments
 (0)