forked from INTER-Mediator/INTER-Mediator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataConverter_Number.php
47 lines (42 loc) · 1.28 KB
/
DataConverter_Number.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* INTER-Mediator
* Copyright (c) INTER-Mediator Directive Committee (http://inter-mediator.org)
* This project started at the end of 2009 by Masayuki Nii msyk@msyk.net.
*
* INTER-Mediator is supplied under MIT License.
* Please see the full license for details:
* https://github.com/INTER-Mediator/INTER-Mediator/blob/master/dist-docs/License.txt
*
* @copyright Copyright (c) INTER-Mediator Directive Committee (http://inter-mediator.org)
* @link https://inter-mediator.com/
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
require_once('DataConverter_NumberBase.php');
class DataConverter_Number extends DataConverter_NumberBase
{
private $d = null;
private $isZeroNoString = false;
/**
*
* @param
* @return
*/
function __construct($digits = 0)
{
parent::__construct();
if ($digits === true) {
$this->isZeroNoString = true;
$this->d = 0;
} else {
$this->d = $digits;
}
}
function converterFromDBtoUser($str)
{
if ($this->isZeroNoString && (double)$str == 0) {
return "";
}
return number_format((double)$str, (int)($this->d), $this->decimalMark, $this->thSepMark);
}
}