sheenazien8/konstantiq

1.0.0 2025-01-05 01:43 UTC

This package is auto-updated.

Last update: 2025-01-05 01:53:24 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is a simple package that helps you manage your constant values. The root cause of this library is that sometimes you need the status in the view or the API response, but you have more than one status. You can look at the example below.

<?php

class SomeClass 
{
    // This method returns an array of status strings
    public function pain(): array
    {
        return [
            'Pending',
            'Failed',
            'Done'
        ];
    }

    // This method returns an array of status constants from PaymentStatus
    public function healthy(): array
    {
        return PaymentStatus::all()->toArray();
    }
}

Installation

You can install the package via composer:

composer require sheenazien8/konstantiq

You can publish the config file with:

php artisan vendor:publish --tag="konstantiq-config"

Usage

php artisan make:constant PaymentStatus #it will generate class \App\Constants\PaymentStatus
<?php

namespace App\Constants;

use Sheenazien8\Konstantiq\ConstanstAbstraction;

class PaymentStatus extends ConstanstAbstraction
{
    // You can add the constants that you need
    const PENDING = 'pending';
    const DONE = 'done';
}

// Usage example
PaymentStatus::PENDING; // will return the 'pending' value
PaymentStatus::all(); // will return the all of the constants

Testing

composer test

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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