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

Collapse   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A collapseWords() 0 7 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.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