2017 © Pedro Peláez
 

library type-enum

Simple and fast implementation of enumerations with native PHP 5.4 and upper

image

skinka/type-enum

Simple and fast implementation of enumerations with native PHP 5.4 and upper

  • Saturday, July 30, 2016
  • by Skinka
  • Repository
  • 2 Watchers
  • 7 Stars
  • 1,711 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 4 % Grown

The README.md

PHP type Enum implementation

It's an abstract class that needs to be extended to use enumeration., (*1)

What is an Enumeration?, (*2)

Install

Add skinka/type-enum to the project's composer.json dependencies and run php composer.phar install, (*3)

Usage

Create enum

<?php

namespace skinka\php\TypeEnum\enums;

use skinka\php\TypeEnum\BaseEnum;

/**
 * Class to enumerations of YES or NO status
 *
 * @method static YesNo YES()
 * @method static YesNo NO()
 * @method string text()
 */

class YesNo extends BaseEnum
{
    const YES = 1;
    const NO = 0;

    public static function getData() {
        return [
            self::YES => [
                'text' => 'Yes',
            ],
            self::NO => [
                'text' => 'No',
            ]
        ];
    }
}

Use enum example

YesNo::getDataList(); //[0 => 'No', 1 => 'Yes']

YesNo::getKeys(); //[0,1]

YesNo::NO(); //0

YesNo::YES()->text(); //Yes

YesNo::YES()->getValue(); //1

YesNo::YES()->getArray(); //['text' => 'Yes']

YesNo::getByValue(0)->text(); //No

YesNo::getByName('YES'); //1

The Versions

30/07 2016

dev-master

9999999-dev http://github.com/skinka/type-enum

Simple and fast implementation of enumerations with native PHP 5.4 and upper

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar Skinka

enum enumeration

30/07 2016

1.0.3

1.0.3.0 http://github.com/skinka/type-enum

Simple and fast implementation of enumerations with native PHP 5.4 and upper

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar Skinka

enum enumeration

30/07 2016

1.0.2

1.0.2.0 http://github.com/skinka/type-enum

Simple and fast implementation of enumerations with native PHP 5.4 and upper

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar Skinka

enum enumeration

12/06 2016

1.0.1

1.0.1.0 http://github.com/skinka/type-enum

Simple and fast implementation of enumerations with native PHP 5.4 and upper

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar Skinka

enum enumeration

26/04 2016

1.0.0

1.0.0.0 http://github.com/skinka/type-enum

Simple and fast implementation of enumerations with native PHP 5.4 and upper

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar Skinka

enum enumeration

26/01 2016

0.1.1

0.1.1.0 http://github.com/skinka/type-enum

Simple and fast implementation of enumerations with native PHP 5.4 and upper

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar Skinka

enum enumeration