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

brick / geo / 17456208570

04 Sep 2025 07:10AM UTC coverage: 50.432%. Remained the same
17456208570

push

github

BenMorel
Use @extends and @implements instead of @template-* variants

For consistency with the rest of the project.

1867 of 3702 relevant lines covered (50.43%)

1140.21 hits per line

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

82.35
/src/Projector/RemoveZmProjector.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Brick\Geo\Projector;
6

7
use Brick\Geo\CoordinateSystem;
8
use Brick\Geo\Point;
9
use Override;
10

11
use function assert;
12

13
/**
14
 * Removes the Z and/or M coordinates of a geometry.
15
 */
16
final class RemoveZmProjector implements Projector
17
{
18
    public function __construct(
19
        private readonly bool $removeZ = false,
20
        private readonly bool $removeM = false,
21
    ) {
22
    }
8✔
23

24
    #[Override]
25
    public function project(Point $point): Point
26
    {
27
        $coordinateSystem = $this->getTargetCoordinateSystem($point->coordinateSystem());
8✔
28

29
        if ($point->isEmpty()) {
8✔
30
            return new Point($coordinateSystem);
×
31
        }
32

33
        $x = $point->x();
8✔
34
        $y = $point->y();
8✔
35
        $z = $point->z();
8✔
36
        $m = $point->m();
8✔
37

38
        assert($x !== null);
39
        assert($y !== null);
40

41
        $coords = [$x, $y];
8✔
42

43
        if (! $this->removeZ && $z !== null) {
8✔
44
            $coords[] = $z;
×
45
        }
46

47
        if (! $this->removeM && $m !== null) {
8✔
48
            $coords[] = $m;
×
49
        }
50

51
        return new Point($coordinateSystem, ...$coords);
8✔
52
    }
53

54
    #[Override]
55
    public function getTargetCoordinateSystem(CoordinateSystem $sourceCoordinateSystem): CoordinateSystem
56
    {
57
        return $sourceCoordinateSystem
8✔
58
            ->withZ($sourceCoordinateSystem->hasZ() && ! $this->removeZ)
8✔
59
            ->withM($sourceCoordinateSystem->hasM() && ! $this->removeM);
8✔
60
    }
61
}
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