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

The-oGlow / ezlogging / 25566499297

08 May 2026 04:18PM UTC coverage: 92.573% (+1.7%) from 90.832%
25566499297

push

github

web-flow
Merge pull request #14 from The-oGlow/develop

TaskList & Bugfixes

215 of 234 new or added lines in 10 files covered. (91.88%)

536 of 579 relevant lines covered (92.57%)

14.56 hits per line

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

89.47
/src/Tools/String/ToStringTrait.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 ollily\Tools\String;
15

16
trait ToStringTrait
17
{
18
    use ImplodeTrait;
19

20
    /**
21
     * @return mixed
22
     *
23
     * @SuppressWarnings("PHPMD.CamelCaseMethodName")
24
     */
25
    abstract protected function __toStringValues();  // NOSONAR: php:S100
26

27
    /**
28
     * @inheritdoc
29
     */
30
    public function __toString()
9✔
31
    {
32
        $value = $this->__toStringValues();
9✔
33
        if (is_string($value)) {
9✔
34
            $toString = sprintf('%s:\'%s\'', get_class($this), $value);
2✔
35
        } elseif (is_scalar($value)) {
7✔
36
            $toString = sprintf('%s:%s', get_class($this), (string)$value);
2✔
37
        } elseif (is_array($value)) {
5✔
38
            foreach (array_keys($value) as $arrayKey) {
4✔
39
                if (is_object($value[$arrayKey]) && $this == $value[$arrayKey]) {
4✔
NEW
40
                    $value[$arrayKey] = get_class($value[$arrayKey]);
×
41
                }
42
            }
43
            $toString = sprintf('%s:[%s]', get_class($this), implode(',', $value));
4✔
44
        } elseif (is_object($value)) {
2✔
45
            if ($this == $value) {
2✔
46
                $toString = sprintf('{%s}', print_r($value, true));
1✔
47
            } else {
48
                $toString = sprintf('%s:{%s}', get_class($this), print_r($value, true));
1✔
49
            }
50
        } else {
51
            $toString = sprintf('%s', get_class($this));
×
52
        }
53

54
        return $toString;
9✔
55
    }
56

57
    /**
58
     * @inheritdoc
59
     */
60
    public function __wakeup()
1✔
61
    {
62
        throw new \BadMethodCallException("Cannot unserialize singleton");
1✔
63
    }
64
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc