sfneal/actions

Abstraction layers for utilizing the 'Action' pattern in PHP applications

2.1.0 2024-03-29 19:57 UTC

This package is auto-updated.

Last update: 2024-12-16 16:48:28 UTC


README

Packagist PHP support Latest Version on Packagist Build Status StyleCI Scrutinizer Code Quality Total Downloads

Abstraction layers for utilizing the "Action" pattern in PHP applications.

Installation

You can install the package via composer:

composer require sfneal/actions

Usage

Here's a basic example of an action class that accepts a string parameter to the contructor and then outputs the string in all caps from the execute method.

use Sfneal\Actions\AbstractAction;

class MockAction extends AbstractAction
{
    /**
     * @var mixed|string
     */
    private $string;
    
    /**
     * MockAction constructor.
     * 
     * @param string $string
     */
    public function __construct($string = 'output')
    {
        $this->string = $string;
    }
    
    /**
     * Execute the action.
     *
     * @return mixed
     */
    public function execute()
    {
        return strtoupper($this->string);
    }
}
$output = (new MockAction('string'))->execute();
>>> 'STRING'

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email stephen.neal14@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.