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

The-oGlow / ezkoding / 28334935713

28 Jun 2026 08:26PM UTC coverage: 77.741% (-1.7%) from 79.436%
28334935713

push

github

ollily
#2: updat tasklist

16 of 32 new or added lines in 7 files covered. (50.0%)

3 existing lines in 1 file now uncovered.

475 of 611 relevant lines covered (77.74%)

6.06 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
10✔
26
    {
27
        $value = $this->__toStringValues();
10✔
28
        if (is_string($value)) {
10✔
29
            $toString = sprintf('%s:\'%s\'', get_class($this), $value);
1✔
30
        } elseif (is_scalar($value)) {
9✔
31
            $toString = sprintf('%s:%s', get_class($this), (string)$value);
×
32
        } elseif (is_array($value)) {
9✔
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)) {
9✔
40
            if ($this == $value) {
9✔
41
                $toString = sprintf('{%s}', print_r($value, true));
8✔
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;
10✔
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