Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.
/ constants Public archive

[Deprecated] Validate and retrieve your application-level global constants

License

Notifications You must be signed in to change notification settings

koomai/constants

Repository files navigation

DEPRECATED!

This package has been deprecated. Check out the following packages:

Constants

Constants is a helper package for validating and retrieving application-level global constants/enums.

Build Status StyleCI

Contents

Installation

composer require koomai/constants:^1.0

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

  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)

It will return $status if it's a valid constant value or throw an InvalidConstantException.

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

LeadStatus::has($status)

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

LeadStatus::all()

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Credits

License

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