• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

The-oGlow / ezlogging / 17529812692

07 Sep 2025 02:26PM UTC coverage: 73.543%. Remained the same
17529812692

push

github

ollily
#3: Traits added

0 of 4 new or added lines in 1 file covered. (0.0%)

164 of 223 relevant lines covered (73.54%)

6.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Tools/String/ImplodeTrait.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of ezlogging
7
 *
8
 * (c) 2025 Oliver Glowa, coding.glowa.com
9
 *
10
 * This source file is subject to the Apache-2.0 license that is bundled
11
 * with this source code in the file LICENSE.
12
 */
13

14
namespace oglowa\tools\Yacorapi\Helper;
15

16
trait ImplodeTrait
17
{
18
    /**
19
     * Recursively implodes an array with optional key inclusion.
20
     *
21
     * Example of $include_keys output: key, value, key, value, key, value
22
     *
23
     * @param string $separator   value that glues elements together
24
     * @param mixed  $anyData     multi-dimensional array to recursively implode
25
     * @param bool   $displayKeys include keys before their values
26
     *
27
     * @return string imploded array
28
     */
NEW
29
    protected function arrayRecImplode(string $separator, $anyData, bool $displayKeys = false): string
×
30
    {
31
        $output      = '';
×
32
        $value_index = 0;
×
33
        if (is_array($anyData) || is_object($anyData)) {
×
34
            foreach ($anyData as $key => $value) {
×
NEW
35
                $output .= ($value_index ? $separator : '') . ($displayKeys ? (is_int($key) ? $key : "'" . $key . "'") . '=>' : '');
×
36
                if (is_array($value)) {
×
NEW
37
                    $array_ouput = $this->arrayRecImplode($separator, $value, $displayKeys);
×
38
                    if ($array_ouput) {
×
39
                        $output .= '[' . $array_ouput . ']';
×
40
                    } else {
41
                        $output .= '[]';
×
42
                    }
43
                } else {
44
                    if (is_object($value)) {
×
NEW
45
                        $object_output = $this->arrayRecImplode($separator, $value, $displayKeys);
×
46
                        if ($object_output) {
×
47
                            $output .= '{' . $object_output . '}';
×
48
                        } else {
49
                            $output .= '{}';
×
50
                        }
51
                    } else {
52
                        $output .= '"' . $value . '"';
×
53
                    }
54
                }
55
                $value_index++;
×
56
            }
57
        } else {
58
            $output = $anyData;
×
59
        }
60

61
        return $output;
×
62
    }
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc