TripletsConverter::numberToTriplets()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 1
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\Concerns;
9
10
/**
11
 * @author Vuong Minh <[email protected]>
12
 * @since 1.0.0
13
 */
14
trait TripletsConverter
15
{
16
    /**
17
     * Chia số truyền vào thành các cụm gồm 3 số để hổ trợ cho việc chuyển sang chữ số.
18
     *
19
     * @param int $number
20
     * @return array|int[]
21
     */
22
    protected function numberToTriplets(int $number): array
23
    {
24
        $result = [];
25
26
        while (0 < $number) {
27
            array_unshift($result, $number % 1000);
28
            $number = (int) ($number / 1000);
29
        }
30
31
        return $result;
32
    }
33
}
34