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

The-oGlow / ezlogging / 18278713918

06 Oct 2025 11:02AM UTC coverage: 84.295% (+2.2%) from 82.105%
18278713918

push

github

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

Develop

148 of 175 new or added lines in 13 files covered. (84.57%)

12 existing lines in 2 files now uncovered.

263 of 312 relevant lines covered (84.29%)

13.63 hits per line

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

57.14
/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()
1✔
31
    {
32
        // @phpstan-ignore function.alreadyNarrowedType
33
        if (method_exists($this, '__toStringValues')) {
1✔
34
            $value = $this->__toStringValues();
1✔
35
            if (is_string($value)) {
1✔
NEW
36
                $toString = sprintf('%s:\'%s\'', get_class($this), $value);
×
37
            } elseif (is_scalar($value)) {
1✔
NEW
38
                $toString = sprintf('%s:%s', get_class($this), (string)$value);
×
39
            } elseif (is_array($value)) {
1✔
NEW
40
                foreach (array_keys($value) as $arrayKey) {
×
NEW
41
                    if (is_object($value[$arrayKey]) && $this == $value[$arrayKey]) {
×
NEW
42
                        $value[$arrayKey] = get_class($value[$arrayKey]);
×
43
                    }
44
                }
NEW
45
                $toString = sprintf('%s:[%s]', get_class($this), implode(',', $value));
×
46
            } elseif (is_object($value)) {
1✔
47
                if ($this == $value) {
1✔
48
                    $toString = sprintf('{%s}', print_r($value, true));
1✔
49
                } else {
NEW
50
                    $toString = sprintf('%s:{%s}', get_class($this), print_r($value, true));
×
51
                }
52
            } else {
NEW
53
                $toString = sprintf('%s', get_class($this));
×
54
            }
55
        } else {
NEW
56
            $toString = sprintf('%s', get_class($this));
×
57
        }
58

59
        return $toString;
1✔
60
    }
61

62
    /**
63
     * @inheritdoc
64
     */
65
    public function __wakeup()
1✔
66
    {
67
        throw new \BadMethodCallException("Cannot unserialize singleton");
1✔
68
    }
69
}
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