for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PHPAlgorithms\GraphTools;
use PHPAlgorithms\GraphTools\Interfaces\LineInterface;
use PHPAlgorithms\GraphTools\Exceptions\LineException;
use PHPAlgorithms\GraphTools\Traits\MagicGet;
use PHPAlgorithms\GraphTools\Traits\toArray;
class AbstractLine implements LineInterface {
use MagicGet, toArray;
protected $from, $to;
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.
protected function checkPoints($from, $to)
{
if ($from->equals($to)) {
throw new LineException('You can not build the line from the same point');
}
protected function checkPoint($point)
if (!($point instanceof AbstractPoint)) {
throw new LineException('This is not a point');
protected function setFrom($from)
$this->checkPoint($from);
$this->from = $from;
protected function setTo($to)
$this->checkPoint($to);
$this->to = $to;
public function __construct($from, $to)
$this->setFrom($from);
$this->setTo($to);
$this->checkPoints($from, $to);
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.