public function testDifference()
 {
     $checker = new Checker();
     $checker->addValue(Checker::CREDIT, 5.0);
     $checker->addValue(Checker::DEBIT, 4.99);
     $this->assertEquals(0.01, $checker->getDifference());
 }
Exemple #2
0
 /**
  * Validação de Valores
  *
  * @param  string $value Valor para Verificação
  * @return bool   Confirmação do Validador
  */
 public function doValidateValue($value)
 {
     // Inicialização
     $checker = new Checker();
     $formatter = new NumberFormatter(null, NumberFormatter::CURRENCY);
     // Configuração de Símbolo
     $formatter->setSymbol(NumberFormatter::CURRENCY_SYMBOL, '');
     // Tipos e Valores
     if (isset($this->data['entries']) && is_array($this->data['entries'])) {
         foreach ($this->data['entries'] as $entry) {
             if (is_array($entry) && isset($entry['type']) && isset($entry['value'])) {
                 // Capturar Valor Monetário
                 $value = $formatter->parseCurrency($entry['value'], $currency);
                 // Limpeza PHPMD
                 unset($currency);
                 // Adicionar Entrada
                 switch ($entry['type']) {
                     case Checker::CREDIT:
                     case Checker::DEBIT:
                         $checker->addValue($entry['type'], $value);
                         break;
                 }
             }
         }
     }
     // Validação
     return $checker->isValid();
 }