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

The-oGlow / ezkoding / 32839533896

25 Aug 2026 10:53AM UTC coverage: 86.082% (+0.8%) from 85.249%
32839533896

push

github

ollily
Merge commit '55d80e110'

232 of 270 new or added lines in 12 files covered. (85.93%)

8 existing lines in 3 files now uncovered.

569 of 661 relevant lines covered (86.08%)

7.55 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
    /**
21
     * @SuppressWarnings("PHPMD.CamelCaseMethodName")
22
     */
23
    abstract protected function __toStringValues(): mixed;  // NOSONAR: php:S100
24

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

49
        return $toString;
11✔
50
    }
51

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