Completed
Pull Request — master (#2)
by Oguzhan
05:49 queued 03:06
created

ArrayTrait::recursiveJoin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Pbxg33k\Traits;
4
5
trait ArrayTrait
6
{
7
    /**
8
     * Recusively implodes an array
9
     *
10
     * @param array $array
11
     * @param string $glue
12
     *
13
     * @return string
14
     */
15
    public function recusiveImplode(array $array, $glue = ',')
16
    {
17
        foreach($array as $key => $element) {
18
            if(is_array($element)) {
19
                $array[$key] = $this->recusiveImplode($element, $glue);
20
            }
21
        }
22
23
        return implode($glue, $array);
24
    }
25
26
    /**
27
     * Alias for recursiveImplode
28
     *
29
     * @param array $array
30
     * @param string $glue
31
     * @return string
32
     */
33
    public function recursiveJoin(array $array, $glue = ',')
34
    {
35
        return $this->recusiveImplode($array, $glue);
36
    }
37
}