Conditions | 2 |
Paths | 2 |
Total Lines | 11 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
43 | public static function fromTwoPoints(Point $a, Point $b) |
||
44 | { |
||
45 | if ($a->getX() === $b->getX()) { |
||
46 | throw new \RuntimeException('Line can be defined only by two points with different X'); |
||
47 | } |
||
48 | |||
49 | $k = ($a->getY() - $b->getY()) / ($a->getX() - $b->getX()); |
||
50 | $n = $a->getY() - $k * $a->getX(); |
||
51 | |||
52 | return new self($k, $n); |
||
53 | } |
||
54 | |||
65 |