pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/olegstyle/enum

> GitHub - olegstyle/enum · GitHub
Skip to content

olegstyle/enum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Enumerator

Requires

PHP >= 7.1

Installation

1. Append to composer package requires

composer require olegstyle/enum

2. Use it ^_^

Usage

1. Create new class

/**
 * -- Magic methods
 * @method static static EXPIRED()
 * @method static static ERROR()
 * @method static static STARTED()
 * @method static static PENDING()
 * @method static static DONE()
 */
class StatusEnum extends OlegStyle\Enum\Enum
{
    EXPIRED = -2;
    ERROR = -1;
    STARTED = 0;
    PENDING = 1;
    DONE  = 2;
}

2. use it like this

$started = StatusEnum::STARTED(); // will return Enum object by magik command
$error = StatusEnum::instanceFromValue(-1); // will be created object from value
$expired = new StatusEnum(-2); // will be created object from value

$isExpired = $started->isEqual(StatusEnum::EXPIRED()); // will be returned false
$isExpired2 = $expired->isEqual(-2); // will be returned true 
$isExpired3 = $started->isEqual('0'); // will be returned false because is using strict mode comparation
$isStartedKey = $started->isEqualKey('STARTED'); // will be returned true
$isStartedKeyEnum = $started->isEqualKey(StatusEnum::STARTED()); // will be returned true

$array = StatusEnum::toArray(); // will be return all constants from StatusEnum class
$pendingKey = StatusEnum::search(1); // will be returned contant name - 'PENDING'
$unknownKey = StatusEnum::search('1'); // will be returned null because is using strict mode
$pendingKey = StatusEnum::getName(1); // similar to search

StatusEnum::isValid(2); // valid key. should be returned true
StatusEnum::isValid('2'); // should be returned false because is using strict mode

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy