for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Location\Utility\Corridor;
use Location\Bearing\BearingInterface;
use Location\Line;
use Location\Polygon;
class LineCorridor
{
/**
* @var float distance between line and the corridor border, in meters
*/
private $distance;
* @var \Location\Bearing\BearingInterface
private $bearingCalculator;
* LineCorridor constructor.
*
* @param float $distance
public function __construct($distance, BearingInterface $bearingCalculator)
if ($distance <= 0.0) {
throw new \InvalidArgumentException("distance must be greater than 0");
}
$this->distance = $distance;
$this->bearingCalculator = $bearingCalculator;
public function createCorridor(Line $line)
$line
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
throw new \RuntimeException("Method not implemented yet.");
$corridor = new Polygon();
$corridor = new \Location\Polygon();
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.
return
die
exit
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.
return false
$bearingForward = $line->getBearing($this->bearingCalculator);
$bearingReverse = $line->getReverse()->getBearing($this->bearingCalculator);
$corridor->addPoint($this->bearingCalculator->calculateDestination($line->getPoint1(), fmod($bearingForward + 135, 360), $this->distance));
$corridor->addPoint($this->bearingCalculator->calculateDestination($line->getPoint1(), fmod($bearingForward - 135, 360), $this->distance));
$corridor->addPoint($this->bearingCalculator->calculateDestination($line->getPoint2(), fmod($bearingReverse - 135, 360), $this->distance));
$corridor->addPoint($this->bearingCalculator->calculateDestination($line->getPoint2(), fmod($bearingReverse + 135, 360), $this->distance));
return $corridor;
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.