Skip to content

Commit 7f481fe

Browse files
committed
add twitter method to SocialShareableGenerator
1 parent 6c4a1a6 commit 7f481fe

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/SocialShareableGenerator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public function x(array $params = []): string
2929
return "https://x.com/intent/tweet?{$query}";
3030
}
3131

32+
public function twitter(array $params = []): string
33+
{
34+
return $this->x($params);
35+
}
36+
3237
public function facebook(array $params = []): string
3338
{
3439
$queryParams = array_merge([

tests/SocialShareableGeneratorTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ public function can_pass_custom_parameters_to_x(): void
5959
$this->assertStringContainsString('via=escuelait', $xUrl);
6060
}
6161

62+
#[Test]
63+
public function x_method_returns_same_as_twitter_method(): void
64+
{
65+
$url = 'https://escuela.it';
66+
$title = 'My Awesome Article';
67+
68+
$generator = SocialShareableGenerator::for($url, $title);
69+
70+
$xUrl = $generator->x();
71+
$twitterUrl = $generator->twitter();
72+
73+
$this->assertEquals($xUrl, $twitterUrl);
74+
}
75+
6276
#[Test]
6377
public function can_generate_facebook_share_url(): void
6478
{

0 commit comments

Comments
 (0)