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

brick / geo / 13970069988

20 Mar 2025 01:07PM UTC coverage: 65.472%. First build
13970069988

push

github

BenMorel
Introduce ProxyRegistry

71 of 595 new or added lines in 19 files covered. (11.93%)

1881 of 2873 relevant lines covered (65.47%)

1472.18 hits per line

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

85.71
/src/Internal/ProxyRegistry.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Brick\Geo\Internal;
6

7
use Brick\Geo\Geometry;
8
use Brick\Geo\Proxy\ProxyInterface;
9
use WeakMap;
10

11
/**
12
 * This registry is a temporary fix to allow the Geometry class hierarchy to be readonly.
13
 * We'll get rid of proxies soon by leveraging PHP 8.4's native proxy objects.
14
 */
15
final class ProxyRegistry
16
{
17
    /**
18
     * @var WeakMap<ProxyInterface&Geometry, Geometry>|null
19
     */
20
    private static ?WeakMap $proxies = null;
21

22
    /**
23
     * @template T of Geometry
24
     *
25
     * @param ProxyInterface&T $proxy
26
     *
27
     * @return T|null
28
     */
29
    public static function getProxiedGeometry(ProxyInterface&Geometry $proxy): ?Geometry
30
    {
31
        if (self::$proxies === null) {
441✔
32
            /** @var WeakMap<ProxyInterface&Geometry, Geometry> */
33
            self::$proxies = new WeakMap();
8✔
34
        }
35

36
        /** @var T|null */
37
        return self::$proxies[$proxy] ?? null;
441✔
38
    }
39

40
    public static function hasProxiedGeometry(ProxyInterface&Geometry $proxy) : bool
41
    {
42
        return self::$proxies !== null && isset(self::$proxies[$proxy]);
8✔
43
    }
44

45
    /**
46
     * @template T of Geometry
47
     *
48
     * @param ProxyInterface&T $proxy
49
     * @param T $geometry
50
     */
51
    public static function setProxiedGeometry(ProxyInterface&Geometry $proxy, Geometry $geometry): void
52
    {
53
        if (self::$proxies === null) {
441✔
54
            /** @var WeakMap<ProxyInterface&Geometry, Geometry> */
NEW
55
            self::$proxies = new WeakMap();
×
56
        }
57

58
        self::$proxies[$proxy] = $geometry;
441✔
59
    }
60
}
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