Completed
Push — master ( aec035...22a1ab )
by Marcus
02:38
created

LineCorridor::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 2
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)
0 ignored issues
show
Unused Code introduced by
The parameter $line is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
37
    {
38
        throw new \RuntimeException("Method not implemented yet.");
39
40
        $corridor = new Polygon();
0 ignored issues
show
Unused Code introduced by
$corridor = new \Location\Polygon(); does not seem to be reachable.

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 or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

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.

Loading history...
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