TripletsConverter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A numberToTriplets() 0 11 2
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