Completed
Pull Request — master (#4)
by
unknown
09:27
created

Collapse::collapseWords()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
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.2.0
13
 */
14
trait Collapse
15
{
16
    /**
17
     * Ghép mảng chữ số thành chuỗi.
18
     *
19
     * @param  array|string[]  $words
20
     * @return string
21
     * @since 1.2.0
22
     */
23
    protected function collapseWords(array $words): string
24
    {
25
        $separator = $this->dictionary->separator();
0 ignored issues
show
Bug introduced by
The property dictionary does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
26
        $words = array_filter($words);
27
28
        return implode($separator, $words);
29
    }
30
}
31