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