2017 © Pedro Peláez
 

library constants

An easy and clean way to manage application-level global constants

image

koomai/constants

An easy and clean way to manage application-level global constants

  • Thursday, March 8, 2018
  • by koomai
  • Repository
  • 1 Watchers
  • 1 Stars
  • 313 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 1390 % Grown

The README.md

DEPRECATED!

This package has been deprecated. Check out the following packages:, (*1)

  • https://github.com/myclabs/php-enum
  • https://github.com/BenSampo/laravel-enum

Constants

Constants is a helper package for validating and retrieving application-level global constants/enums., (*2)

Build Status StyleCI, (*3)

Contents

Installation

composer require koomai/constants:^1.0, (*4)

Usage

  1. Simply extend your class from Koomai\Constants\Constants and define your constants. E.g.,
<?php

namespace App\Constants;

use Koomai\Constants\Constants as AbstractConstants;

class LeadStatus extends AbstractConstants
{
    const ATTEMPTED = 'attempted';
    const CONTACTED = 'contacted';
    const OPPORTUNITY = 'opportunity';
    const DISQUALIFIED = 'disqualified';
}

  1. For internal use in your code, you just reference the constant name directly as usual:

LeadStatus::CONTACTED, (*5)

  1. When doing look-ups, e.g. via user input or as a parameter in a method, use the static get() method:

LeadStatus::get($status), (*6)

It will return $status if it's a valid constant value or throw an InvalidConstantException., (*7)

  1. If you don't want an exception thrown, you can check if the value exists first:

LeadStatus::has($status), (*8)

  1. To retrieve an array of all the constants in a class:

LeadStatus::all(), (*9)

Changelog

Please see CHANGELOG for more information what has changed recently., (*10)

Testing

bash $ composer test, (*11)

Contributing

Please see CONTRIBUTING for details., (*12)

Credits

License

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

The Versions

08/03 2018

dev-master

9999999-dev https://github.com/laravel-notification-channels/:package_name

An easy and clean way to manage application-level global constants

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

07/03 2018

v1.0.1

1.0.1.0 https://github.com/laravel-notification-channels/:package_name

An easy and clean way to manage application-level global constants

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

11/12 2017

v1.0.0

1.0.0.0 https://github.com/laravel-notification-channels/:package_name

An easy and clean way to manage application-level global constants

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires