gluon-web-remote

Web remote Administration for big size of gluon routers
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-web-remote.git
Log | Files | Refs | README

Util.php (973B)


      1 <?php
      2 /*
      3  * This file is part of the PHP_CodeCoverage package.
      4  *
      5  * (c) Sebastian Bergmann <sebastian@phpunit.de>
      6  *
      7  * For the full copyright and license information, please view the LICENSE
      8  * file that was distributed with this source code.
      9  */
     10 
     11 /**
     12  * Utility methods.
     13  *
     14  * @since Class available since Release 1.0.0
     15  */
     16 class PHP_CodeCoverage_Util
     17 {
     18     /**
     19      * @param  float $a
     20      * @param  float $b
     21      * @return float ($a / $b) * 100
     22      */
     23     public static function percent($a, $b, $asString = false, $fixedWidth = false)
     24     {
     25         if ($asString && $b == 0) {
     26             return '';
     27         }
     28 
     29         if ($b > 0) {
     30             $percent = ($a / $b) * 100;
     31         } else {
     32             $percent = 100;
     33         }
     34 
     35         if ($asString) {
     36             if ($fixedWidth) {
     37                 return sprintf('%6.2F%%', $percent);
     38             }
     39 
     40             return sprintf('%01.2F%%', $percent);
     41         } else {
     42             return $percent;
     43         }
     44     }
     45 }