1. Go to this page and download the library: Download femastudios/enums library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
femastudios / enums example snippets
/**
* @method static Greeting HELLO()
* @method static Greeting GOOD_MORNING()
* @method static Greeting GOOD_EVENING()
*/
final class Greeting extends \com\femastudios\enums\DocEnum {}
Greeting::HELLO(); // Will return a Greeting instance
/**
*
* @method static Day MONDAY()
* @method static Day TUESDAY()
* @method static Day WEDNESDAY()
* @method static Day THURSDAY()
* @method static Day FRIDAY()
* @method static Day SATURDAY()
* @method static Day SUNDAY()
*/
final class Day extends \com\femastudios\enums\DocEnum {}
/**
*
* @method static Day MONDAY()
* @method static Day TUESDAY()
* @method static Day WEDNESDAY()
* @method static Day THURSDAY()
* @method static Day FRIDAY()
* @method static Day SATURDAY()
* @method static Day SUNDAY()
*/
final class Day extends \com\femastudios\enums\ConstEnum {
private const ENUM_MONDAY = ['Mon', true];
private const ENUM_TUESDAY = ['Tue', true];
private const ENUM_WEDNESDAY = ['Wen', true];
private const ENUM_THURSDAY = ['Thu', true];
private const ENUM_FRIDAY = ['Fri', true];
private const ENUM_SATURDAY = ['Sat', false];
private const ENUM_SUNDAY = ['Sun', false];
private $abbreviation, $isWorkDay;
private function __construct(string $abbreviation, bool $isWorkDay) {
parent::__construct();
$this->abbreviation = $abbreviation;
$this->isWorkDay = $isWorkDay;
}
public function getAbbreviation() : string {
return $this->abbreviation;
}
public function isWorkDay() : bool {
return $this->isWorkDay;
}
}
/**
* @method static IntAlgorithm SUM()
* @method static IntAlgorithm DIFF()
* @method static IntAlgorithm MULT()
* @method static IntAlgorithm DIV()
*/
final class IntAlgorithm extends \com\femastudios\enums\MethodEnum {
private $alg;
private function __construct(callable $alg) {
parent::__construct();
$this->alg = $alg;
}
public function getAlg() : callable {
return $this->alg;
}
public function invokeAlg(int $a, int $b) : int {
return ($this->alg)($a, $b);
}
private static function ENUM_SUM() : IntAlgorithm {
return new IntAlgorithm(function (int $a, int $b) {
return $a + $b;
});
}
private static function ENUM_DIFF() : IntAlgorithm {
return new IntAlgorithm(function (int $a, int $b) {
return $a - $b;
});
}
private static function ENUM_MULT() : IntAlgorithm {
return new IntAlgorithm(function (int $a, int $b) {
return $a * $b;
});
}
private static function ENUM_DIV() : IntAlgorithm {
return new IntAlgorithm(function (int $a, int $b) {
return intdiv($a, $b);
});
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.