public function testFormatting()
 {
     $obj = new DollarFormatter(98.59999999999999);
     $this->assertSame('$98.60', $obj->get());
     $obj = new DollarFormatter();
     $this->assertSame('$0.00', $obj->get());
     $obj = new DollarFormatter('$125.00');
     $this->assertSame('$125.00', $obj->get());
     $obj = new DollarFormatter('$65');
     $this->assertSame('$65.00', $obj->get());
     $obj = new DollarFormatter('123456');
     $this->assertSame('$123,456.00', $obj->get());
 }
Esempio n. 2
0
 public function formatColumn($column, $format_code)
 {
     $formatter = NULL;
     switch ($format_code) {
         case 'USD':
             $formatter = new DollarFormatter();
             break;
     }
     if (empty($formatter)) {
         return;
     }
     // Iterate all pages, all records on column and format cell
     $data = $this->getData();
     foreach ($data->getAllPageIds() as $page_id) {
         $page = $data->getPage($page_id);
         foreach ($page as $record_id => $row) {
             if (isset($row[$column])) {
                 $formatter->set($row[$column]);
                 $data->setPage($page_id);
                 $data->setPointer($record_id);
                 $data->add($column, $formatter->get());
             }
         }
     }
     return $this->compile();
 }