Esempio n. 1
0
 /**
  * Calculate result percent difference
  *
  * @param int $best    float Best test result
  * @param int $current float Result for comparison
  *
  * @return array [CliColor, string]
  */
 private function getPercentDiff($best, $current)
 {
     $diff = $current - $best;
     $percent = $best / 100;
     $value = $diff / $percent;
     $result = new CliColor();
     if ($value > 0 and $value <= 10) {
         $color = 'yellow';
         $value = number_format($value, 2);
         $string = "-{$value}";
     } elseif ($value > 10) {
         $color = 'red';
         $value = number_format($value, 2);
         $string = "-{$value}";
     } else {
         $color = 'green';
         $value = number_format($value, 2);
         $string = "+{$value}";
     }
     $result->setColor($color);
     $result->setstring($string);
     return [$result, $color];
 }
Esempio n. 2
0
 /**
  * Calculate result percent difference
  *
  * @param $best float Best test result
  * @param $current float Result for comparison
  * @return CliColor
  */
 private static function getPercentDiff($best, $current)
 {
     $diff = $current - $best;
     $percent = $best / 100;
     $value = $diff / $percent;
     $result = new CliColor();
     if ($value > 0) {
         $value = number_format($value, 2);
         $result->setColor('red');
         $result->setstring("-{$value}");
     } else {
         $value = number_format($value, 2);
         $result->setColor('green');
         $result->setstring("+{$value}");
     }
     return $result;
 }
 /**
  * @covers       Veles\Tools\CliColor::setColor
  * @dataProvider setColorExceptionProvider
  * @expectedException \Exception
  *
  * @param $color
  */
 public function testSetColorException($color)
 {
     $this->object->setColor($color);
 }