These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Location\Utility\Corridor; |
||
4 | |||
5 | use Location\Bearing\BearingInterface; |
||
6 | use Location\Line; |
||
7 | use Location\Polygon; |
||
8 | |||
9 | class LineCorridor |
||
10 | { |
||
11 | /** |
||
12 | * @var float distance between line and the corridor border, in meters |
||
13 | */ |
||
14 | private $distance; |
||
15 | |||
16 | /** |
||
17 | * @var \Location\Bearing\BearingInterface |
||
18 | */ |
||
19 | private $bearingCalculator; |
||
20 | |||
21 | /** |
||
22 | * LineCorridor constructor. |
||
23 | * |
||
24 | * @param float $distance |
||
25 | */ |
||
26 | public function __construct($distance, BearingInterface $bearingCalculator) |
||
27 | { |
||
28 | if ($distance <= 0.0) { |
||
29 | throw new \InvalidArgumentException("distance must be greater than 0"); |
||
30 | } |
||
31 | |||
32 | $this->distance = $distance; |
||
33 | $this->bearingCalculator = $bearingCalculator; |
||
34 | } |
||
35 | |||
36 | public function createCorridor(Line $line) |
||
37 | { |
||
38 | throw new \RuntimeException("Method not implemented yet."); |
||
39 | |||
40 | $corridor = new Polygon(); |
||
0 ignored issues
–
show
|
|||
41 | |||
42 | $bearingForward = $line->getBearing($this->bearingCalculator); |
||
43 | $bearingReverse = $line->getReverse()->getBearing($this->bearingCalculator); |
||
44 | |||
45 | $corridor->addPoint($this->bearingCalculator->calculateDestination($line->getPoint1(), fmod($bearingForward + 135, 360), $this->distance)); |
||
46 | $corridor->addPoint($this->bearingCalculator->calculateDestination($line->getPoint1(), fmod($bearingForward - 135, 360), $this->distance)); |
||
47 | $corridor->addPoint($this->bearingCalculator->calculateDestination($line->getPoint2(), fmod($bearingReverse - 135, 360), $this->distance)); |
||
48 | $corridor->addPoint($this->bearingCalculator->calculateDestination($line->getPoint2(), fmod($bearingReverse + 135, 360), $this->distance)); |
||
49 | |||
50 | return $corridor; |
||
51 | } |
||
52 | } |
||
53 |
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.