Giter VIP home page Giter VIP logo

laravel-str-acronym's Introduction

social.png

Installation

You can install the package using Composer:

composer require koenhendriks/laravel-str-acronym

After installing the package Laravel should automatically discover the package.

If you want you can register the service provider in your Laravel application manually. You can do this by adding the service provider to the providers array in your config/app.php file:

'providers' => [
    KoenHendriks\StrAcronym\StrServiceProvider::class,
],

Once you've registered the service provider, you can start using the acronym macro in your Laravel application.

Usage

To generate an acronym from a string, you can call the acronym method on the Str helper:

use Illuminate\Support\Str;

$acronym = Str::acronym('Hello World'); // Returns 'HW'

If you prefer to use the Fluent Strings, you can call the acronym method on a Stringable object:

use Illuminate\Support\Str;

$acronym = Str::of('hello world')->headline()->acronym(); // Returns 'HW'

You can also provide a delimiter string as an optional parameter to separate the acronym letters:

use Illuminate\Support\Str;

$acronym = Str::acronym('Hello World', '.'); // Returns 'H.W.'
$acronym = Str::of('hello world')->headline()->acronym(); // Returns 'H.W.'

Testing

This package is using PhpUnit to unit test the macros. A simple alias has been created with composer to run the tests.

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

This package originates from this Pull Request on the Laravel Framework

Contributors

License

This package is licensed under the MIT License. See the LICENSE file for more information.

Contributing

If you find any issues with the package or have suggestions for improvements, feel free to open an issue or pull request on the GitHub repository.

laravel-str-acronym's People

Contributors

koenhendriks avatar dependabot[bot] avatar github-actions[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.