dealroom/socials-helpers

Helper package used for the validation of social links


README

Test & Release Quality Gate Status Maintainability Test Coverage

Socials Helpers

Helper package used for the validation of social links.

Requirements

This project requires PHP 8.1 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\Parser;

$data = Factory::parseUrl('http://twitter.com/Dealroom', [Parser::PLATFORM_TWITTER])->getNormalizedUrl();

echo $data;

// "https://twitter.com/dealroom"

Or if you want to extract social network ID (handle):

use Dealroom\SocialsHelpers\Factory;
use Dealroom\SocialsHelpers\Parser;

$data = Factory::parseUrl('https://twitter.com/dealroom', [Parser::PLATFORM_TWITTER])->getId();

echo $data;

// "dealroom"

Testing

PHPUnit is used for testing, just 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.