| Conditions | 6 |
| Paths | 12 |
| Total Lines | 26 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 45 | public function evaluate($x) |
||
| 46 | { |
||
| 47 | $nowPoint = new Point($x, 0); |
||
| 48 | |||
| 49 | $containingLine = null; |
||
| 50 | foreach ($this->path->getLineIterator() as $line) { |
||
| 51 | if ($nowPoint->betweenX($line->getStartPoint(), $line->getEndPoint())) { |
||
| 52 | $containingLine = $line; |
||
| 53 | break; |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | if (null === $containingLine) { |
||
| 58 | if (false === $this->extrapolate) { |
||
| 59 | return null; |
||
| 60 | } |
||
| 61 | |||
| 62 | if ($this->path->firstPoint()->getX() > $x) { |
||
| 63 | $containingLine = $this->path->firstLine(); |
||
| 64 | } else { |
||
| 65 | $containingLine = $this->path->lastLine(); |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | return $containingLine->getLinearFunction()->evaluate($x); |
||
| 70 | } |
||
| 71 | } |
||
| 72 |