2017 © Pedro Peláez
 

library enum

PHP implementation of Enum with strict comparisons

image

tuscanicz/enum

PHP implementation of Enum with strict comparisons

  • Wednesday, April 25, 2018
  • by tuscanicz
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4,900 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 5 Versions
  • 17 % Grown

The README.md

Strict enum

PHP implementation of Enum with strict comparisons, (*1)

<?php

use Enum\AbstractEnum;

class Day extends AbstractEnum
{
    const SUNDAY = 0;
    const MONDAY = 1;
    const TUESDAY = 2;
    const WEDNESDAY = 3;
    const THURSDAY = 4;
    const FRIDAY = 5;
    const SATURDAY = 6;

    protected static $default = self::SUNDAY;

    public function getLabel()
    {
        return date('l', strtotime(sprintf('Sunday + %d Days', $this->getValue())));
    }
}

$defaultDay = new Day();
echo $defaultDay->getValue();
// 0
echo $defaultDay->getLabel();
// Sunday

$monday = new Day(Day::MONDAY);
echo $monday->getValue();
// 1
echo $monday;
// 1
print_r(Day::getValues());
// Array ( [SUNDAY] => 0 [MONDAY] => 1 [TUESDAY] => 2 [WEDNESDAY] => 3 [THURSDAY] => 4 [FRIDAY] => 5 [SATURDAY] => 6 )
echo $monday->getLabel();
// Monday
print_r(Day::getLabels());
// Array ( [0] => Sunday [1] => Monday [2] => Tuesday [3] => Wednesday [4] => Thursday [5] => Friday [6] => Saturday )

Contribute

Build Status, (*2)

Feel free to contribute!, (*3)

Please, run the tests via phpunit php vendor/phpunit/phpunit/phpunit and keep the code coverage., (*4)

The Versions

25/04 2018

dev-master

9999999-dev

PHP implementation of Enum with strict comparisons

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Karel Štefan
by Petr Bechyne

enum

22/06 2017

v2.0.2

2.0.2.0

PHP implementation of Enum with strict comparisons

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Karel Štefan
by Petr Bechyne

enum

22/06 2017

v2.0.1

2.0.1.0

PHP implementation of Enum with strict comparisons

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Karel Štefan
by Petr Bechyne

enum

22/06 2017

v2.0

2.0.0.0

PHP implementation of Enum with strict comparisons

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Karel Štefan
by Petr Bechyne

enum

20/06 2013

1.0

1.0.0.0

PHP implementation of Enum

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Karel Štefan

enum