dealroom/socials-helpers 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dealroom/socials-helpers

最新稳定版本:v4.123.76

Composer 安装命令:

composer require dealroom/socials-helpers

包简介

Helper package used for the validation and normalization of social media links

README 文档

README

Test & Release Quality Gate Status codecov

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
  • Facebook
  • Instagram
  • LinkedIn
  • Twitter
  • 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.

统计信息

  • 总下载量: 74.12k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 6
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-02