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

The-oGlow / ezkoding / 40125643554

24 Oct 2026 07:30PM UTC coverage: 80.655% (-3.8%) from 84.414%
40125643554

push

github

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

Develop

11 of 13 new or added lines in 8 files covered. (84.62%)

13 existing lines in 3 files now uncovered.

517 of 641 relevant lines covered (80.66%)

7.73 hits per line

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

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

46
        return $toString;
10 ✔
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