forked from mapasculturais/mapasculturais
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standardize social media fields to accept both URLs and usernames.
- Loading branch information
1 parent
4b9d244
commit ec1618e
Showing
13 changed files
with
328 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Enum; | ||
|
||
enum SocialMediaEnum: string | ||
{ | ||
case FACEBOOK = 'facebook.com'; | ||
case INSTAGRAM = 'instagram.com'; | ||
case LINKEDIN = 'linkedin.com'; | ||
case PINTEREST = 'pinterest.com'; | ||
case SPOTIFY = 'spotify.com'; | ||
case X = 'x.com'; | ||
case VIMEO = 'vimeo.com'; | ||
case YOUTUBE = 'youtube.com'; | ||
case TIKTOK = 'tiktok.com'; | ||
|
||
public function getParsingRegex(): string | ||
{ | ||
return match ($this) { | ||
self::FACEBOOK, self::INSTAGRAM, self::PINTEREST, self::VIMEO => "/(?:{$this->value}\/(?:profile\.php\?id=)?|^)([\w\d\.]+)$/i", | ||
|
||
self::X, self::YOUTUBE, self::TIKTOK => "/(?:{$this->value}\/|^)(@?[\w\d\.]+)$/i", | ||
|
||
self::LINKEDIN => "/(?:{$this->value}\/in\/|^)([\w\d-]+)$/i", | ||
|
||
self::SPOTIFY => "/(?:open\.)?spotify\.com\/(?:intl-\w+\/)?(?:(user|artist)\/([\w\d]+))|^(user|artist)\/([\w\d]+)$/i", | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.