XoopsLocal::number_format()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * Xoops locale
14
 *
15
 * @copyright       (c) 2000-2020 XOOPS Project (www.xoops.org)
16
 * @license             GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html)
17
 * @package             kernel
18
 * @since               2.3.0
19
 * @author              Taiwen Jiang <[email protected]>
20
 * @todo                To be handled by i18n/l10n
21
 */
22
defined('XOOPS_ROOT_PATH') || exit('Restricted access');
23
24
setlocale(LC_ALL, 'en_US');
25
26
// !!IMPORTANT!! insert '\' before any char among reserved chars: "a","A","B","c","d","D","e","F","g","G","h","H","i","I","j","l","L","m","M","n","O","r","s","S","t","T","U","w","W","Y","y","z","Z"
27
// insert double '\' before 't','r','n'
28
define('_TODAY', "\T\o\d\a\y G:i");
29
define('_YESTERDAY', "\Y\\e\s\\t\\e\\r\d\a\y G:i");
30
define('_MONTHDAY', 'n/j G:i');
31
define('_YEARMONTHDAY', 'Y/n/j G:i');
32
define('_ELAPSE', '%s ago');
33
define(
34
    '_TIMEFORMAT_DESC',
35
    'Valid formats: "s" - '
36
    . _SHORTDATESTRING
37
    . '; "m" - '
38
    . _MEDIUMDATESTRING
39
    . '; "l" - '
40
    . _DATESTRING
41
    . ';<br>'
42
    . '"c" or "custom" - format determined according to interval to present; "e" - Elapsed; "mysql" - Y-m-d H:i:s;<br>'
43
    . 'specified string - Refer to <a href="http://php.net/manual/en/function.date.php" rel="external">PHP manual</a>.'
44
);
45
46
if (!class_exists('XoopsLocalAbstract')) {
47
    require_once XOOPS_ROOT_PATH . '/class/xoopslocal.php';
48
}
49
50
/**
51
 * A Xoops Local
52
 *
53
 * @package             kernel
54
 * @subpackage          Language
55
 *
56
 * @author              Taiwen Jiang <[email protected]>
57
 * @copyright       (c) 2000-2020 XOOPS Project (www.xoops.org)
58
 */
59
class XoopsLocal extends XoopsLocalAbstract
60
{
61
    /**
62
     * Number Formats
63
     *
64
     * @param unknown_type $number
0 ignored issues
show
Bug introduced by
The type unknown_type was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
65
     * @return unknown
0 ignored issues
show
Bug introduced by
The type unknown was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
66
     */
67
    public function number_format($number)
68
    {
69
        return number_format($number, 2, '.', ',');
0 ignored issues
show
Bug Best Practice introduced by
The expression return number_format($number, 2, '.', ',') returns the type string which is incompatible with the documented return type unknown.
Loading history...
Bug introduced by
$number of type unknown_type is incompatible with the type double expected by parameter $num of number_format(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

69
        return number_format(/** @scrutinizer ignore-type */ $number, 2, '.', ',');
Loading history...
70
    }
71
72
    /**
73
     * Money Format
74
     *
75
     * @param string $format
76
     * @param string $number
77
     * @return money  format
0 ignored issues
show
Bug introduced by
The type money was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
78
     */
79
    public function money_format($format, $number)
80
    {
81
        setlocale(LC_MONETARY, 'en_US');
82
83
        return money_format($format, $number);
0 ignored issues
show
Bug Best Practice introduced by
The expression return money_format($format, $number) also could return the type string which is incompatible with the documented return type money.
Loading history...
Bug introduced by
$number of type string is incompatible with the type double expected by parameter $number of money_format(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

83
        return money_format($format, /** @scrutinizer ignore-type */ $number);
Loading history...
84
    }
85
}
86