PHP code example of macrominds / enum
1. Go to this page and download the library: Download macrominds/enum 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/ */
macrominds / enum example snippets
// example for type hinted function
public function save(Salutation $salutation) {
saveToDB($salutation->value());
}
// example for fetching the enum from value
public function load($value) {
// throws \Exception if $value is invalid
return Salutation::fromValue($value);
}
// example for fetching the enum from key
public function loadKey($key) {
// throws \Exception if $key is invalid
return Salutation::fromKey($key);
}