vjik/linkify

Matches things like email addresses, web URLs, etc. in the text and makes them clickable links.

1.0.0 2022-03-15 14:31 UTC

This package is auto-updated.

Last update: 2024-12-15 20:17:53 UTC


README

Latest Stable Version Total Downloads Build status Mutation testing badge static analysis

The package provide Linkify class that matches things like email addresses, web URLs, etc. in the text and makes them clickable links.

Requirements

  • PHP 7.4 or higher.

Installation

The package could be installed with composer:

composer require vjik/linkify --prefer-dist

General usage

$linkify = new \Vjik\Linkify\Linkify(
    new \Vjik\Linkify\HttpPattern(),
    new \Vjik\Linkify\EmailPattern(),
); 

$text = 'Contacts: https://example.com, info@example.com.';

$result = $linkify->process($text);

$result will be:

Contacts: <a href="https://example.com">example.com</a>, <a href="mailto:info@example.com">info@example.com</a>.

Testing

Unit testing

The package is tested with PHPUnit. To run tests:

./vendor/bin/phpunit

Mutation testing

The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:

./vendor/bin/roave-infection-static-analysis-plugin

Static analysis

The code is statically analyzed with Psalm. To run static analysis:

./vendor/bin/psalm

License

The Linkify is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.