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

  enum Coin {
    penny(1), nickel(5), dime(10), quarter(25);

    public function color() {
      switch ($this->ordinal) {
        case self::penny: return 'copper';
        case self::nickel: return 'nickel';
        case self::dime: case self::quarter: return 'silver';
      }
    }
  }


  // {{{ main
  echo 'Coin (', Coin::size(), " values):\n";
  foreach (Coin::values() as $coin) {
    echo '* ', $coin->name, ': ', $coin->ordinal, ' (', $coin->color(), ")\n";
  }
  // }}}
?><commit_msg>- Refactor switch() statement into a hash lookup - Add __toString() method<commit_after><?php
/* This file is part of the XP framework's experiments
 *
 * $Id$
 */

  enum Coin {
    penny(1), nickel(5), dime(10), quarter(25);

    protected static $color= array(
      self::penny   => 'copper',
      self::nickel  => 'nickel',
      self::dime    => 'silver',
      self::quarter => 'silver'
    );

    public function color() {
      return self::$color[$this->ordinal];
    }
    
    public function __toString() {
      return $this->name.': '.$this->ordinal.' ('.$this->color().')';
    }
  }


  // {{{ main
  echo 'Coin (', Coin::size(), " values):\n";
  foreach (Coin::values() as $coin) {
    echo '* ', $coin, "\n";
  }
  // }}}
?>
{'fraction_non_alphanumeric': 0.21123595505617979, 'fraction_numerical': 0.008988764044943821, 'mean_word_length': 2.6205962059620598, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '2870866', 'n_tokens_mistral': 481, 'n_tokens_neox': 455, 'n_words': 113}