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

The-oGlow / ezkoding / 35610251881

21 Sep 2026 01:56PM UTC coverage: 85.553%. Remained the same
35610251881

push

github

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

Develop

169 of 205 new or added lines in 16 files covered. (82.44%)

65 existing lines in 10 files now uncovered.

681 of 796 relevant lines covered (85.55%)

7.47 hits per line

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

68.42
/src/Tools/String/ToStringTrait.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of ezkoding
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
    abstract protected function __toStringValues(): mixed;  // NOSONAR: php:S100
21

22
    public function __toString(): string
11✔
23
    {
24
        $value = $this->__toStringValues();
11✔
25
        if (is_string($value)) {
11✔
26
            $toString = sprintf('%s:\'%s\'', get_class($this), $value);
1✔
27
        } elseif (is_scalar($value)) {
10✔
28
            $toString = sprintf('%s:%s', get_class($this), (string)$value);
×
29
        } elseif (is_array($value)) {
10✔
UNCOV
30
            foreach (array_keys($value) as $arrayKey) {
×
UNCOV
31
                if (is_object($value[$arrayKey]) && $this == $value[$arrayKey]) {
×
32
                    $value[$arrayKey] = get_class($value[$arrayKey]);
×
33
                }
34
            }
UNCOV
35
            $toString = sprintf('%s:[%s]', get_class($this), self::implode_recursive(',', $value));
×
36
        } elseif (is_object($value)) {
10✔
37
            if ($this == $value) {
10✔
38
                $toString = sprintf('{%s}', print_r($value, true));
9✔
39
            } else {
40
                $toString = sprintf('%s:{%s}', get_class($this), print_r($value, true));
1✔
41
            }
42
        } else {
UNCOV
43
            $toString = sprintf('%s', get_class($this));
×
44
        }
45

46
        return $toString;
11✔
47
    }
48

49
    public function __wakeup(): void
1✔
50
    {
51
        throw new \BadMethodCallException("Cannot unserialize singleton");
1✔
52
    }
53
}
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