abstract class DNSRecordType extends Enum { } class A extends DNSRecordType { } class CNAME extends DNSRecordType { } class MX extends DNSRecordType { } class NS extends DNSRecordType { } class SRV extends DNSRecordType { } class TXT extends DNSRecordType { } class AAAA extends DNSRecordType { } class PTR extends DNSRecordType { } echo "DNSRecordType:\n"; foreach (Enum::iterator("DNSRecordType") as $member) { echo "\t" . $member . " has value " . Enum::get($member) . "\n"; }
<?php include "Enum.inc"; abstract class Gender extends Enum { } class Female extends Gender { var $value = "f"; } class Male extends Gender { var $value = "m"; } var_dump(Gender::get("Male") === Male::get("Male")); var_dump(Enum::get("Male") instanceof Gender); var_dump(Enum::get("Male") instanceof Male); var_dump(Gender::get("Male") === Gender::get("Female")); var_dump(Gender::get("female"));
/** * Notify an observer * @link http://php.net/manual/en/splsubject.notify.php * @param $object * @param $action * @internal param Subject $subject * @since 5.1.0 */ public function notify($object, $action) { // var_dump($action); // Notificar observadores $acao = Enum::get($action); // echo "<hr>"; // echo $action."<br>"; // echo $acao."<br>"; // var_dump($object); // die(); foreach ($this->observers as $observer) { $observer->update($object, $action); } }