Exemplo n.º 1
0
 public function testAdd()
 {
     $t = new TallyHolder();
     $baseArray = array('France' => 5, 'Julien' => 10, 'Maurice' => 20, 'Daniel' => 17, 'Canada' => array('Quebec' => 8, 'Ontario' => 15));
     $additive = array('France' => 2, 'Julien' => 5, 'Canada' => array('Quebec' => 3));
     $t->add($baseArray);
     $t->add($additive);
     $expected = array('France' => 7, 'Julien' => 15, 'Maurice' => 20, 'Daniel' => 17, 'Canada' => array('Quebec' => 11, 'Ontario' => 15));
     $this->assertEquals($expected, $t->getTally());
 }
Exemplo n.º 2
0
 public static function getPartyTally($byStatistic = TRUE)
 {
     if ($byStatistic) {
         return self::$partyTally;
     }
     $invertedTally = new TallyHolder();
     $currentTally = self::$partyTally;
     foreach ($currentTally->getTally() as $stat => $partyData) {
         foreach ($partyData as $party => $value) {
             $invertedTally->add(array($party => array($stat => $value)));
         }
     }
     return $invertedTally;
 }