Issues (10)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Dictionary.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * @link https://github.com/phpviet/number-to-words
4
 * @copyright (c) PHP Viet
5
 * @license [MIT](http://www.opensource.org/licenses/MIT)
6
 */
7
8
namespace PHPViet\NumberToWords;
9
10
use InvalidArgumentException;
11
12
/**
13
 * @author Vuong Minh <[email protected]>
14
 * @since 1.0.0
15
 */
16
class Dictionary implements DictionaryInterface
17
{
18
    /**
19
     * Mảng tập hợp hàng đơn vị.
20
     *
21
     * @var array
22
     */
23
    protected static $tripletUnits = [
24
        'không',
25
        'một',
26
        'hai',
27
        'ba',
28
        'bốn',
29
        'năm',
30
        'sáu',
31
        'bảy',
32
        'tám',
33
        'chín',
34
    ];
35
36
    /**
37
     * Mảng tập hợp hàng chục.
38
     *
39
     * @var array
40
     */
41
    protected static $tripletTens = [
42
        '',
43
        'mười',
44
        'hai mươi',
45
        'ba mươi',
46
        'bốn mươi',
47
        'năm mươi',
48
        'sáu mươi',
49
        'bảy mươi',
50
        'tám mươi',
51
        'chín mươi',
52
    ];
53
54
    /**
55
     * Từ ngữ mô tả hàng trăm.
56
     *
57
     * @var string
58
     */
59
    protected static $hundred = 'trăm';
60
61
    /**
62
     * Mảng tập hợp đơn vị tính dựa trên số mũ 3.
63
     *
64
     * @var array
65
     */
66
    protected static $exponents = [
67
        '',
68
        'nghìn',
69
        'triệu',
70
        'tỷ',
71
        'nghìn tỷ',
72
        'triệu tỷ',
73
    ];
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function zero(): string
79
    {
80
        return static::$tripletUnits[0];
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function minus(): string
87
    {
88
        return 'âm';
89
    }
90
91
    /**
92
     * {@inheritdoc}
93
     */
94
    public function separator(): string
95
    {
96
        return ' ';
97
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102
    public function tripletTenSeparator(): string
103
    {
104
        return 'linh';
105
    }
106
107
    /**
108
     * {@inheritdoc}
109
     */
110
    public function specialTripletUnitOne(): string
111
    {
112
        return 'mốt';
113
    }
114
115
    /**
116
     * {@inheritdoc}
117
     */
118
    public function specialTripletUnitFour(): string
119
    {
120
        return 'tư';
121
    }
122
123
    /**
124
     * {@inheritdoc}
125
     */
126
    public function specialTripletUnitFive(): string
127
    {
128
        return 'lăm';
129
    }
130
131
    /**
132
     * {@inheritdoc}
133
     */
134
    public function fraction(): string
135
    {
136
        return 'phẩy';
137
    }
138
139
    /**
140
     * {@inheritdoc}
141
     */
142 View Code Duplication
    public function getTripletUnit(int $unit): string
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
143
    {
144
        if (! isset(static::$tripletUnits[$unit])) {
145
            throw new InvalidArgumentException(sprintf('Unit arg (`%s`) must be in 0-9 range!', $unit));
146
        }
147
148
        return static::$tripletUnits[$unit];
149
    }
150
151
    /**
152
     * {@inheritdoc}
153
     */
154
    public function getTripletTen(int $ten): string
155
    {
156
        if (! isset(static::$tripletTens[$ten])) {
157
            throw new InvalidArgumentException(sprintf('Ten arg (`%s`) must be in 0-9 range!', $ten));
158
        }
159
160
        return static::$tripletTens[$ten];
161
    }
162
163
    /**
164
     * {@inheritdoc}
165
     */
166 View Code Duplication
    public function getTripletHundred(int $hundred): string
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
167
    {
168
        if (! isset(static::$tripletUnits[$hundred])) {
169
            throw new InvalidArgumentException(sprintf('Hundred arg (`%s`) must be in 0-9 range!', $hundred));
170
        }
171
172
        return static::$tripletUnits[$hundred].$this->separator().static::$hundred;
173
    }
174
175
    /**
176
     * {@inheritdoc}
177
     */
178
    public function getExponent(int $power): string
179
    {
180
        if (! isset(static::$exponents[$power])) {
181
            throw new InvalidArgumentException(sprintf('Power arg (`%s`) not exist in vietnamese dictionary!', $power));
182
        }
183
184
        return static::$exponents[$power];
185
    }
186
}
187