<commit_before><?php
/* This file is part of the XP framework's experiments
 *
 * $Id$
 */

  enum Day {
    Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
  }
  
  // {{{ main
  echo "Workdays:\n";
  foreach (range(Day::Monday, Day::Friday) as $number) {
    echo $number, ': ', Day::valueOf($number)->name, "\n";
  }
  // }}}
?><commit_msg>- Add workDays() method which returns an array of Day objects   for every day that is a work day (Monday through Friday) - Add weekend() method which returns an array of Day objects   for every day that is in the weekend (Saturday and Sunday) - Use implode() and array_map() instead of foreach() for display<commit_after><?php
/* This file is part of the XP framework's experiments
 *
 * $Id$
 */

  enum Day {
    Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday;

    private static function isWorkDay(Day $day) {
      return $day->ordinal < self::Saturday;
    }
    
    public static function workDays() {
      return array_filter(self::values(), array('self', 'isWorkDay'));
    }

    private static function isWeekend(Day $day) {
      return $day->ordinal > self::Friday;
    }

    public static function weekend() {
      return array_filter(self::values(), array('self', 'isWeekend'));
    }
  }
  
  function nameOf(Enumeration $e) {
    return $e->name;
  }

  // {{{ main
  echo 'Workdays: ', implode(', ', array_map('nameOf', Day::workDays())), "\n";
  echo 'Weekend:  ', implode(', ', array_map('nameOf', Day::weekend())), "\n";
  // }}}
?>
{'fraction_non_alphanumeric': 0.15676028739386022, 'fraction_numerical': 0.0, 'mean_word_length': 3.3896848137535818, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '802610', 'n_tokens_mistral': 485, 'n_tokens_neox': 463, 'n_words': 153}