PHP 5.5+ enumerator pattern implementation