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

brick / geo / 13753277563

09 Mar 2025 10:43PM UTC coverage: 49.787% (+2.5%) from 47.295%
13753277563

push

github

BenMorel
Prepare for release

1749 of 3513 relevant lines covered (49.79%)

975.53 hits per line

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

46.67
/src/Triangle.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Brick\Geo;
6

7
use Brick\Geo\Attribute\NoProxy;
8
use Brick\Geo\Exception\InvalidGeometryException;
9
use Brick\Geo\Projector\Projector;
10
use Override;
11

12
/**
13
 * A Triangle is a Polygon with 3 distinct, non-collinear vertices and no interior boundary.
14
 *
15
 * @final
16
 */
17
class Triangle extends Polygon
18
{
19
    #[Override]
20
    protected function validate(): void
21
    {
22
        if ($this->isEmpty) {
1,204✔
23
            return;
×
24
        }
25

26
        if ($this->exteriorRing()->numPoints() !== 4) {
1,204✔
27
            throw new InvalidGeometryException('A Triangle must have exactly 4 (3 + first again) points.');
7✔
28
        }
29

30
        if ($this->numInteriorRings() !== 0) {
1,197✔
31
            throw new InvalidGeometryException('A Triangle must not have interior rings.');
7✔
32
        }
33
    }
34

35
    #[NoProxy, Override]
36
    public function geometryType() : string
37
    {
38
        return 'Triangle';
595✔
39
    }
40

41
    #[NoProxy, Override]
42
    public function geometryTypeBinary() : int
43
    {
44
        return Geometry::TRIANGLE;
504✔
45
    }
46

47
    #[Override]
48
    public function project(Projector $projector): Triangle
49
    {
50
        return new Triangle(
×
51
            $projector->getTargetCoordinateSystem($this->coordinateSystem),
×
52
            ...array_map(
×
53
                fn (LineString $ring) => $ring->project($projector),
×
54
                $this->rings,
×
55
            ),
×
56
        );
×
57
    }
58
}
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