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

The-oGlow / ezlogging / 18263869522

05 Oct 2025 08:21PM UTC coverage: 84.516% (+11.0%) from 73.543%
18263869522

push

github

ollily
#1: fix github actions

24 of 36 new or added lines in 3 files covered. (66.67%)

11 existing lines in 4 files now uncovered.

262 of 310 relevant lines covered (84.52%)

13.7 hits per line

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

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

58
        return $toString;
1✔
59
    }
60

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