dealroom / socials-helpers
Helper package used for the validation and normalization of social media links
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Requires
- php: >=8.3
- ext-mbstring: *
Requires (Dev)
- phpunit/phpunit: ^12.0
This package is auto-updated.
Last update: 2026-01-18 07:47:31 UTC
README
Socials Helpers
The helper package which is used for the validation of social links.
Installation
Install via [composer], simply run:
composer require dealroom/socials-helpers
Usage
The Factory class provides a simple wrapper for the validation functionality, for example, to get normalized URL:
use Dealroom\SocialsHelpers\Factory; use Dealroom\SocialsHelpers\Normalizers\TwitterNormalizer; $data = Factory::parseUrl('http://twitter.com/Dealroom', [TwitterNormalizer::getPlatform()])->getNormalizedUrl(); echo $data; // "https://twitter.com/dealroom"
Or if you want to extract social network ID (handle):
use Dealroom\SocialsHelpers\Factory; use Dealroom\SocialsHelpers\Normalizers\TwitterNormalizer; $data = Factory::parseUrl('https://twitter.com/dealroom', [TwitterNormalizer::getPlatform()])->getId(); echo $data; // "dealroom"
Supported Platforms
The following platforms are supported by default:
- Apple Music
- YouTube
- TikTok
- SoundCloud
- X
- Spotify
Registering new platforms
To register a new normalizer, you need to create a new class that implements
the NormalizerInterface interface (for example, by extending the AbstractNormalizer class).
After that, you need to register the new normalizer in the Factory class.
use Dealroom\SocialsHelpers\Normalizers\AbstractNormalizer; use Dealroom\SocialsHelpers\Normalizers\Factory; use Dealroom\SocialsHelpers\Factory; class CustomNormalizer extends AbstractNormalizer { // Implement the interface methods } Factory::addNormalizer(CustomNormalizer::class); $data = Factory::parseUrl('https://custom.com/Dealroom', [CustomNormalizer::getPlatform()])->getNormalizedUrl();
Testing
PHPUnit is used for testing, run:
./vendor/bin/phpunit
Releases and CI/CD
The release is done automatically using GitHub Actions on every push to the main branch.
After the release is done, a new tag is created and pushed to GitHub,
which triggers a new release in packagist.