dealroom / socials-helpers
Helper package used for the validation and normalization of social media links
Requires
- php: >=8.2
- ext-mbstring: *
Requires (Dev)
- phpunit/phpunit: ^11.2
- dev-main
- v4.40.0
- v4.39.0
- v4.38.0
- v4.37.0
- v4.36.0
- v4.35.0
- v4.34.0
- v4.33.0
- v4.32.0
- v4.31.0
- v4.30.0
- v4.29.0
- v4.28.0
- v4.27.0
- v4.26.0
- v4.25.0
- v4.24.0
- v4.23.0
- v4.22.0
- v4.21.0
- v4.20.0
- v4.19.0
- v4.18.0
- v4.17.0
- v4.16.0
- v4.15.0
- v4.14.0
- v4.13.0
- v4.12.0
- v4.11.0
- v4.10.0
- v4.9.0
- v4.8.0
- v4.7.0
- v4.6.0
- v4.5.0
- v4.4.0
- v4.3.0
- v4.2.0
- v4.1.0
- v4.0.0
- v3.88.0
- v3.87.0
- v3.86.0
- v3.85.0
- v3.84.0
- v3.83.0
- v3.82.0
- v3.81.0
- v3.80.0
- v3.79.0
- v3.78.0
- v3.77.0
- v3.76.0
- v3.75.0
- v3.74.0
- v3.73.0
- v3.72.0
- v3.71.0
- v3.70.0
- v3.69.0
- v3.68.0
- v3.67.0
- v3.66.0
- v3.65.0
- v3.64.0
- v3.63.0
- v3.62.0
- v3.61.0
- v3.60.0
- v3.59.0
- v3.58.0
- v3.57.0
- v3.56.0
- v3.55.0
- v3.54.0
- v3.53.0
- v3.52.0
- v3.51.0
- v3.50.0
- v3.49.0
- v3.48.0
- v3.47.0
- v3.46.0
- v3.45.0
- v3.44.0
- v3.43.0
- v3.42.0
- v3.41.0
- v3.40.0
- v3.39.0
- v3.38.0
- v3.37.0
- v3.36.0
- v3.35.0
- v3.34.0
- v3.33.0
- v3.32.0
- v3.31.0
- v3.30.0
- v3.29.0
- v3.28.0
- v3.27.0
- v3.26.0
- v3.25.0
- v3.24.0
- v3.23.0
- v3.22.0
- v3.21.0
- v3.20.0
- v3.19.0
- v3.18.0
- v3.17.0
- v3.16.0
- v3.15.0
- v3.14.0
- v3.13.0
- v3.12.0
- v3.11.0
- v3.10.0
- v3.9.0
- v3.8.0
- v3.7.0
- v3.6.0
- v3.5.0
- v3.4.0
- v3.3.0
- v3.2.0
- v3.1.0
- v3.0.0
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.0
- v1.6.1
- v1.6.0
- v1.5.0
- v1.4.0
- v1.2.0
- v1.1.0
- v1.0.0
- dev-repo-sync/core-mothership/default
This package is auto-updated.
Last update: 2024-11-21 14:55:29 UTC
README
Socials Helpers
Helper package used for the validation of social links.
Requirements
This project requires PHP 8.2 or higher with the mbstring
extension installed.
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.